Java Code Examples for org.apache.activemq.artemis.core.config.Configuration#addAcceptorConfiguration()

The following examples show how to use org.apache.activemq.artemis.core.config.Configuration#addAcceptorConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LargeMessageOverManagementTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
   super.setUp();

   Configuration config = createBasicConfig();


   TransportConfiguration acceptorConfig = createTransportConfiguration(false, true, generateParams(0, false));
   config.addAcceptorConfiguration(acceptorConfig);
   server = createServer(true, config);
   server.setMBeanServer(mbeanServer);
   server.start();

   locator = createInVMNonHALocator().setBlockOnNonDurableSend(true);
   sf = createSessionFactory(locator);
   session = sf.createSession(false, true, false);
   session.start();
   addClientSession(session);
}
 
Example 2
Source File: DirectDeliverTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
   super.setUp();

   Map<String, Object> nettyParams = new HashMap<>();
   nettyParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DIRECT_DELIVER, true);

   TransportConfiguration nettyTransportConfiguration = new TransportConfiguration(NettyAcceptorFactory.class.getName(), nettyParams);

   Map<String, Object> inVMParams = new HashMap<>();
   inVMParams.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.DIRECT_DELIVER, true);

   TransportConfiguration inVMTransportConfiguration = new TransportConfiguration(InVMAcceptorFactory.class.getName(), inVMParams);

   Configuration config = createBasicConfig();
   config.addAcceptorConfiguration(nettyTransportConfiguration);
   config.addAcceptorConfiguration(inVMTransportConfiguration);

   server = createServer(false, config);
   server.start();

   nettyLocator = createNettyNonHALocator();
   addServerLocator(nettyLocator);

   inVMLocator = createInVMLocator(0);
   addServerLocator(inVMLocator);
}
 
Example 3
Source File: Artemis.java    From spring-cloud-ribbon-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void customize(Configuration configuration) {
	//configuration.addAcceptorConfiguration("netty", "tcp://localhost:" + artemisProperties.getPort());
	configuration.addConnectorConfiguration("nettyConnector", new TransportConfiguration(NettyConnectorFactory.class.getName()));
	configuration.addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getName()));
}
 
Example 4
Source File: MQTTTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testDoubleBroker() throws Exception {
   /*
    * Start two embedded server instances for MQTT and connect to them
    * with the same MQTT client id. As those are two different instances
    * connecting to them with the same client ID must succeed.
    */

   final int port1 = 1884;
   final int port2 = 1885;

   final Configuration cfg1 = createDefaultConfig(1, false);
   cfg1.addAcceptorConfiguration("mqtt1", "tcp://localhost:" + port1 + "?protocols=MQTT");

   final Configuration cfg2 = createDefaultConfig(2, false);
   cfg2.addAcceptorConfiguration("mqtt2", "tcp://localhost:" + port2 + "?protocols=MQTT");

   final ActiveMQServer server1 = createServer(cfg1);
   server1.start();
   final ActiveMQServer server2 = createServer(cfg2);
   server2.start();

   final String clientId = "client1";
   final MQTT mqtt1 = createMQTTConnection(clientId, true);
   final MQTT mqtt2 = createMQTTConnection(clientId, true);

   mqtt1.setHost("localhost", port1);
   mqtt2.setHost("localhost", port2);

   final BlockingConnection connection1 = mqtt1.blockingConnection();
   final BlockingConnection connection2 = mqtt2.blockingConnection();

   try {
      connection1.connect();
      connection2.connect();
   } catch (Exception e) {
      fail("Connections should have worked.");
   } finally {
      if (connection1.isConnected())
         connection1.disconnect();
      if (connection2.isConnected())
         connection2.disconnect();
   }
}
 
Example 5
Source File: ArtemisBrokerWrapper.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
private void addServerAcceptor(Configuration serverConfig, BrokerService.ConnectorInfo info) throws Exception {
   serverConfig.addAcceptorConfiguration("homePort" + info.uri.getPort(), info.uri.toString());
}