Skip to content

Commit 96a44bd

Browse files
authored
persistent rabbitmq queue for status (#216)
Create a persistent unique id for clowder instance and use that for the RabbitMQ status queue.
1 parent 79677c0 commit 96a44bd

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
folders and technical metadata. Downloading datasets now includes extra Datacite and Clowder metadata.
1515
- Endpoint /api/files/bulkRemove to delete multiple files in one call. [#12](https://github.com/clowder-framework/clowder/issues/12)
1616
- Log an event each time that a user archives or unarchives a file.
17+
- Clowder will use the same queue for responses, preventing status messages from getting lost.
1718

1819
### Changed
1920
- Updated Sphinx dependencies due to security and changes in required packages.

app/Global.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ object Global extends WithFilters(new GzipFilter(), new Jsonp(), CORSFilter()) w
4545

4646
val users: UserService = DI.injector.getInstance(classOf[UserService])
4747

48+
// get clowder unique ID
49+
Logger.info(s"Starting clowder with id = ${AppConfiguration.getInstance}")
50+
4851
// set the default ToS version
4952
AppConfiguration.setDefaultTermsOfServicesVersion()
5053

app/api/Status.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class Status @Inject()(spaces: SpaceService,
3131

3232
def status = UserAction(needActive=false) { implicit request =>
3333

34-
Ok(Json.obj("version" -> getVersionInfo,
34+
Ok(Json.obj("instance" -> AppConfiguration.getInstance,
35+
"version" -> getVersionInfo,
3536
"counts" -> getCounts(request.user),
3637
"plugins" -> getPlugins(request.user),
3738
"extractors" -> Json.toJson(extractors.getExtractorNames(List.empty))))

app/services/AppConfigurationService.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ trait AppConfigurationService {
7070
object AppConfiguration {
7171
val appConfig: AppConfigurationService = DI.injector.getInstance(classOf[AppConfigurationService])
7272

73+
// ----------------------------------------------------------------------
74+
def getInstance: String = {
75+
appConfig.getProperty[String]("instance") match {
76+
case Some(id) => id
77+
case None => {
78+
val id = scala.util.Random.alphanumeric.take(10).mkString
79+
appConfig.setProperty("instance", id)
80+
id
81+
}
82+
}
83+
}
84+
7385
// ----------------------------------------------------------------------
7486

7587
/** Set the default theme */

app/services/rabbitmq/RabbitMQMessageService.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ class RabbitMQMessageService extends MessageService {
100100
}
101101

102102
// create an anonymous queue for replies
103-
val replyQueueName = channel.get.queueDeclare().getQueue
104-
Logger.debug("Reply queue name: " + replyQueueName)
103+
val replyQueueName = s"clowder.${AppConfiguration.getInstance}"
104+
channel.get.queueDeclare(replyQueueName, true, false, false, null)
105+
Logger.info("Reply queue name: " + replyQueueName)
105106

106107
// get bindings stored in broker
107108
val queueBindingsFuture = getQueuesNamesForAnExchange(exchange)

0 commit comments

Comments
 (0)