private void startActiveMqBroker() throws Exception { this.activeMQBroker = new BrokerService(); this.activeMQBroker.addConnector("stomp://localhost:" + this.port); this.activeMQBroker.setStartAsync(false); this.activeMQBroker.setPersistent(false); this.activeMQBroker.setUseJmx(false); this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5); this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5); this.activeMQBroker.start(); }
@Before public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); brokerService.start(); factory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI()); producerConnection = factory.createConnection(); producerConnection.start(); producerSession = producerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE); queue = producerSession.createQueue(getClass().getName()); producer = producerSession.createProducer(queue); }
@Bean(initMethod = "start", destroyMethod = "stop") @ConditionalOnProperty(prefix = "todo.jms", value = "broker", havingValue = "enabled", matchIfMissing = true) public BrokerService messageBroker() { try { BrokerService messageBroker = BrokerFactory.createBroker(String.format("broker:tcp://%s:%s", brokerHost, brokerPort)); messageBroker.setPersistent(false); messageBroker.setUseJmx(false); return messageBroker; } catch (Exception e) { throw new BeanCreationException("Failed to create embedded message broker", e); } }
@Override public void before() throws Exception { m_temporaryDirectory = Files.createTempDirectory("activemq-data"); m_broker.setPersistent(false); m_broker.setDataDirectory(m_temporaryDirectory.toString()); m_broker.start(); if (!m_broker.waitUntilStarted()) { throw new Exception("ActiveMQ broker was not started or stopped unexpectedly. Error: " + m_broker.getStartException()); } }
//@Configuration public class TestBrokerConfig { @Bean( initMethod = "start", destroyMethod = "stop" ) public BrokerService broker() throws Exception { final BrokerService broker = new BrokerService(); broker.addConnector( "stomp://localhost:61614" ); broker.setPersistent( false ); broker.setShutdownHooks( Collections.< Runnable >singletonList( new SpringContextHook() ) ); final ManagementContext managementContext = new ManagementContext(); managementContext.setCreateConnector( true ); broker.setManagementContext( managementContext ); return broker; } }
/** * Create an embedded ActiveMQ broker using defaults * * The defaults are: * - the broker name is 'embedded-broker' * - JMX is disabled * - Persistence is disabled */ public EmbeddedActiveMQBroker() { brokerService = new BrokerService(); brokerService.setUseJmx(false); brokerService.setUseShutdownHook(false); brokerService.setPersistent(false); brokerService.setBrokerName("embedded-broker"); }
public static void main(String[]args) throws Exception { BrokerService brokerService = new BrokerService(); brokerService.addConnector( "tcp://0.0.0.0:61616?trace=" + TRANSPORT_TRACE + "&transport.wireFormat.maxFrameSize=104857600"); brokerService.setPersistent(false); brokerService.setUseJmx(false); brokerService.setAdvisorySupport(false); brokerService.start(); brokerService.waitUntilStopped(); } }
@Override protected void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); brokerService.start(); factory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI()); consumerConnection = factory.createConnection(); consumerConnection.start(); producerConnection = factory.createConnection(); producerConnection.start(); consumerSession = consumerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE); topic = consumerSession.createTopic(getName()); producerSession = producerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE); consumer = consumerSession.createConsumer(topic); producer = producerSession.createProducer(topic); }
@Override public void before() throws Exception { m_temporaryDirectory = Files.createTempDirectory("activemq-data"); m_broker.setPersistent(false); m_broker.setDataDirectory(m_temporaryDirectory.toString()); m_broker.start(); if (!m_broker.waitUntilStarted()) { throw new Exception("ActiveMQ broker was not started or stopped unexpectedly. Error: " + m_broker.getStartException()); } }
protected BrokerService createBroker(String name, boolean deleteMessagesOnStartup, Map<String, Integer> portMap) throws Exception { BrokerService brokerService = new BrokerService(); brokerService.setBrokerName(name); brokerService.setDeleteAllMessagesOnStartup(deleteMessagesOnStartup); brokerService.setUseJmx(true); brokerService.getManagementContext().setCreateConnector(false); brokerService.setDataDirectory(DATA_PARENT_DIR + File.separator + "data" + File.separator + name); brokerService.setPersistent(false); brokerService.setSchedulerSupport(false); brokerService.setAdvisorySupport(false); ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>(); BrokerPlugin authenticationPlugin = configureAuthentication(); if (authenticationPlugin != null) { plugins.add(authenticationPlugin); } if (!plugins.isEmpty()) { brokerService.setPlugins(plugins.toArray(new BrokerPlugin[0])); } addAdditionalConnectors(brokerService, portMap); return brokerService; }
@Before public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setAdvisorySupport(true); brokerService.setPersistent(false); brokerService.setUseJmx(false); brokerService.start(); }
BrokerService broker = new BrokerService(); broker.setBrokerName("amqbroker"); broker.setPersistent(false); broker.setTransportConnectorURIs(new String[] {"tcp://localhost:61616"}); // setup bridge JmsQueueConnector qCon = new JmsQueueConnector(); JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER); JmsQueueConnectionFactory cf = ff.createQueueConnectionFactory(); cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, "192.168.13.151"); cf.setIntProperty(WMQConstants.WMQ_PORT, 1414); cf.setStringProperty(WMQConstants.WMQ_CHANNEL, "SYSTEM.DEF.SVRCONN"); cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT); cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "SUPERHERO"); qCon.setOutboundQueueConnectionFactory(cf); OutboundQueueBridge outBridge1 = new OutboundQueueBridge("QUEUE42"); qCon.setOutboundQueueBridges(new OutboundQueueBridge[] {outBridge1}); broker.setJmsBridgeConnectors(new JmsConnector[] {qCon}); broker.start();
@BeforeAll public static void initialize() throws Exception { BROKER.setPersistent(false); BROKER.start(); }
@Autowired public ActiveMqMessagingService(DaemonThreadStatsCollector daemonThreadStatsCollector) throws Exception { this.daemonThreadStatsCollector = daemonThreadStatsCollector; SystemEnvironment systemEnvironment = new SystemEnvironment(); broker = new BrokerService(); broker.setBrokerName(BROKER_NAME); broker.setPersistent(false); broker.setUseJmx(systemEnvironment.getActivemqUseJmx()); broker.getManagementContext().setConnectorPort(systemEnvironment.getActivemqConnectorPort()); broker.start(); factory = new ActiveMQConnectionFactory(BROKER_URL); factory.getPrefetchPolicy().setQueuePrefetch(systemEnvironment.getActivemqQueuePrefetch()); factory.setCopyMessageOnSend(false); connection = (ActiveMQConnection) factory.createConnection(); connection.start(); }
@BeforeAll public void setUp() throws Exception { BROKER.setPersistent(false); BROKER.start(); APP.before(); CLIENT = new JerseyClientBuilder(APP.getEnvironment()).build("test client"); CLIENT.property(CONNECT_TIMEOUT, 10000); CLIENT.property(READ_TIMEOUT, 12000); setDefaultPollInterval(100L, MILLISECONDS); }
@Before public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); brokerService.setPlugins(new BrokerPlugin[] { new BrokerPluginSupport() { @Override public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception { LOG.info("Remove Connection called for connection [{}] with error: {}", info.getConnectionId(), error); removeException.set(error); super.removeConnection(context, info, error); } }}); stealableConnectionURI = brokerService.addConnector("tcp://0.0.0.0:0?allowLinkStealing=true").getPublishableConnectString(); unstealableConnectionURI = brokerService.addConnector("tcp://0.0.0.0:0?allowLinkStealing=false").getPublishableConnectString(); brokerService.start(); }
@Before public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); brokerService.setUseJmx(true); String connectionUri = brokerService.addConnector("tcp://localhost:0").getPublishableConnectString(); brokerService.start(); brokerService.waitUntilStarted(); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri); final Connection conn = connectionFactory.createConnection(); try { conn.start(); final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); final Destination queue = session.createQueue(testQueueName); final Message toSend = session.createMessage(); toSend.setStringProperty("foo", "bar"); final MessageProducer producer = session.createProducer(queue); producer.send(queue, toSend); } finally { conn.close(); } }
@Before public void setUp() throws Exception { logger.debug("Setting up before '" + this.testName.getMethodName() + "'"); int port = SocketUtils.findAvailableTcpPort(61613); this.activeMQBroker = new BrokerService(); this.activeMQBroker.addConnector("stomp://127.0.0.1:" + port); this.activeMQBroker.setStartAsync(false); this.activeMQBroker.setPersistent(false); this.activeMQBroker.setUseJmx(false); this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5); this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5); this.activeMQBroker.start(); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.afterPropertiesSet(); this.client = new ReactorNettyTcpStompClient("127.0.0.1", port); this.client.setMessageConverter(new StringMessageConverter()); this.client.setTaskScheduler(taskScheduler); }
@Before public void startBroker() throws Exception { broker = new BrokerService(); broker.setPersistent(false); TransportConnector connector = broker.addConnector(new TransportConnector()); connector.setUri(new URI("tcp://0.0.0.0:0")); connector.setName("tcp"); broker.start(); broker.waitUntilStarted(); brokerConnectURI = broker.getConnectorByName("tcp").getConnectUri(); }
public void start() { broker = new BrokerService(); try { broker.setUseJmx(false); broker.setPersistent(false); transportConnector = broker.addConnector(connectorUrl); broker.start(true); broker.waitUntilStarted(); } catch (Exception e) { throw new RuntimeException(e); } }