Skip to content

Commit

Permalink
JAMES-2101 Use consants in EmbeddedActiveMQ
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa committed Jul 27, 2017
1 parent 030c74a commit 34e47df
Showing 1 changed file with 14 additions and 8 deletions.
Expand Up @@ -40,16 +40,22 @@
public class EmbeddedActiveMQ {

private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedActiveMQ.class);
private static final String KAHADB_STORE_LOCATION = "file://var/store/activemq/brokers/KahaDB";
private static final String BLOB_TRANSFER_LOCATION = "file://var/store/activemq/blob-transfer";
private static final String BROCKERS_LOCATION = "file://var/store/activemq/brokers";
private static final String BROKER_ID = "broker";
private static final String BROKER_NAME = "james";
private static final String BROCKER_URI = "tcp://localhost:0";

private final ActiveMQConnectionFactory activeMQConnectionFactory;
private final PersistenceAdapter persistenceAdapter;
private BrokerService brokerService;

@Inject
private EmbeddedActiveMQ(FileSystem fileSystem, PersistenceAdapter persistenceAdapter) {
private EmbeddedActiveMQ(FileSystem fileSystem, PersistenceAdapter persistenceAdapter) {
this.persistenceAdapter = persistenceAdapter;
try {
persistenceAdapter.setDirectory(fileSystem.getFile("file://var/store/activemq/brokers/KahaDB"));
persistenceAdapter.setDirectory(fileSystem.getFile(KAHADB_STORE_LOCATION));
launchEmbeddedBroker(fileSystem);
} catch (Exception e) {
throw Throwables.propagate(e);
Expand Down Expand Up @@ -82,29 +88,29 @@ private ActiveMQPrefetchPolicy createActiveMQPrefetchPolicy() {

private BlobTransferPolicy createBlobTransferPolicy(FileSystem fileSystem) {
FileSystemBlobTransferPolicy blobTransferPolicy = new FileSystemBlobTransferPolicy();
blobTransferPolicy.setDefaultUploadUrl("file://var/store/activemq/blob-transfer");
blobTransferPolicy.setDefaultUploadUrl(BLOB_TRANSFER_LOCATION);
blobTransferPolicy.setFileSystem(fileSystem);
return blobTransferPolicy;
}

private void launchEmbeddedBroker(FileSystem fileSystem) throws Exception {
brokerService = new BrokerService();
brokerService.setBrokerName("james");
brokerService.setBrokerName(BROKER_NAME);
brokerService.setUseJmx(false);
brokerService.setPersistent(true);
brokerService.setDataDirectoryFile(fileSystem.getFile("file://var/store/activemq/brokers"));
brokerService.setDataDirectoryFile(fileSystem.getFile(BROCKERS_LOCATION));
brokerService.setUseShutdownHook(false);
brokerService.setSchedulerSupport(false);
brokerService.setBrokerId("broker");
String[] uris = {"tcp://localhost:0"};
brokerService.setBrokerId(BROKER_ID);
String[] uris = {BROCKER_URI};
brokerService.setTransportConnectorURIs(uris);
ManagementContext managementContext = new ManagementContext();
managementContext.setCreateConnector(false);
brokerService.setManagementContext(managementContext);
brokerService.setPersistenceAdapter(persistenceAdapter);
BrokerPlugin[] brokerPlugins = {new StatisticsBrokerPlugin()};
brokerService.setPlugins(brokerPlugins);
String[] transportConnectorsURIs = {"tcp://localhost:0"};
String[] transportConnectorsURIs = {BROCKER_URI};
brokerService.setTransportConnectorURIs(transportConnectorsURIs);
brokerService.start();
LOGGER.info("Started embedded activeMq");
Expand Down

0 comments on commit 34e47df

Please sign in to comment.