Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use CloudAMPQ addon instead of private RabbitMQ

  • Loading branch information...
commit a824d23ce951bf13074c597e3161c5bfedeca5cd 1 parent bb6f865
Ryan Brainard ryanbrainard authored
7 README.md
View
@@ -4,7 +4,8 @@ As explained in the [Worker Dynos, Background Jobs and Queueing](background-jobs
should be completed as fast as possible. If an operation may take a long time, it is best to send it to a worker
dyno to be processed in the background. This article demostrates this with an example application using Spring
[MVC](http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html) and
-[AMPQ](http://www.springsource.org/spring-amqp) with the Heroku [RabbitMQ add-on](https://addons.heroku.com/rabbitmq).
+[AMPQ](http://www.springsource.org/spring-amqp) with the Heroku [CloudAMPQ add-on](https://addons.heroku.com/cloudamqp),
+which provides [RabbitMQ](http://www.rabbitmq.com/) as a service.
### Clone the Reference Application
@@ -23,14 +24,14 @@ The `web` and `worker` processes can be scaled independently depending on applic
The application is structured as a Maven multi-module project with `web` and `worker` modules for each of the two
processes as well as a shared `common` module. The `common` module contains the common `BigOperation` model class and the
-`RabbitConfiguration` class that reads the `RABBITMQ_URL` environment variable provided by the RabbitMQ add-on and
+`RabbitConfiguration` class that reads the `CLOUDAMQP_URL` environment variable provided by the RabbitMQ add-on and
makes it available to the rest of the application:
@Bean
public ConnectionFactory connectionFactory() {
final URI rabbitMqUrl;
try {
- rabbitMqUrl = new URI(getEnvOrThrow("RABBITMQ_URL"));
+ rabbitMqUrl = new URI(getEnvOrThrow("CLOUDAMQP_URL"));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
14 common/src/main/java/com/heroku/devcenter/RabbitConfiguration.java
View
@@ -19,19 +19,19 @@
@Bean
public ConnectionFactory connectionFactory() {
- final URI rabbitMqUrl;
+ final URI ampqUrl;
try {
- rabbitMqUrl = new URI(getEnvOrThrow("RABBITMQ_URL"));
+ ampqUrl = new URI(getEnvOrThrow("CLOUDAMQP_URL"));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
final CachingConnectionFactory factory = new CachingConnectionFactory();
- factory.setUsername(rabbitMqUrl.getUserInfo().split(":")[0]);
- factory.setPassword(rabbitMqUrl.getUserInfo().split(":")[1]);
- factory.setHost(rabbitMqUrl.getHost());
- factory.setPort(rabbitMqUrl.getPort());
- factory.setVirtualHost(rabbitMqUrl.getPath().substring(1));
+ factory.setUsername(ampqUrl.getUserInfo().split(":")[0]);
+ factory.setPassword(ampqUrl.getUserInfo().split(":")[1]);
+ factory.setHost(ampqUrl.getHost());
+ factory.setPort(ampqUrl.getPort());
+ factory.setVirtualHost(ampqUrl.getPath().substring(1));
return factory;
}
Please sign in to comment.
Something went wrong with that request. Please try again.