You could potentially simplify your configuration code as follows...

  Configuration config = new ConfigurationImpl()
     .setJournalType(JournalType.NIO)
     .setPersistenceEnabled(true)
     .setSecurityEnabled(false)
     .addAcceptorConfiguration(new 
TransportConfiguration(InVMAcceptorFactory.class.getName()))
     .addAcceptorConfiguration(new 
TransportConfiguration(NettyAcceptorFactory.class.getName(), params))
     .addAddressesSetting("jms.queue.*", new AddressSettings()
        .setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE)
        .setMaxSizeBytes(30 * 1024 * 1024)
        .setPageSizeBytes(10 * 1024 * 1024)
        .setPageCacheMaxSize(20));

The connector was removed because if your clients use URIs then you don't need 
a connector.  Here is an example URI that would be equivalent to what you had 
previously - vm://0?reconnectAttempts=-1&minLargeMessageSize=250000.  
Connection monitoring is disabled by default so you don't need to set 
clientFailureCheckPeriod or connectionTTL explicitly.  Also, HA defaults to 
false so there no real need to set that either.  Here's an example using the 
client code you provided:

  ConnectionFactory connectionFactory = new 
ActiveMQConnectionFactory("vm://0?reconnectAttempts=-1&minLargeMessageSize=250000");
  javax.jms.Connection consumerConnection = 
connectionFactory.createConnection();
  javax.jms.Connection producerConnection = 
connectionFactory.createConnection();

I also removed the queue configurations because JMS queues are now auto-created 
by default so there's no need to configure them explicitly unless you just want 
to.  Also, instead of looking the queues up the clients can simply instantiate 
them using the JMS API javax.jms.Session#createQueue or even 
org.apache.activemq.artemis.api.jms.ActiveMQJMSClient#createQueue.

The other main difference here is the utilization of the fluent API to string 
together all the method calls which eliminates a lot of code duplication.

Regarding messages that don't get consumed, I'd need a bit more information 
about your use-case and the circumstances around the unconsumed messages to 
comment further.


Justin

----- Original Message -----
From: "ipolevoy" <i...@expresspigeon.com>
To: users@activemq.apache.org
Sent: Wednesday, January 27, 2016 8:58:23 PM
Subject: Re: ActiveMQ does not send some messages

Hi, Justin. 

here is some compressed code that shows configuration: 
Configuration config = new ConfigurationImpl();
        JMSConfiguration jmsConfig = new JMSConfigurationImpl();
        config.setJournalType(JournalType.NIO);
        config.setPersistenceEnabled(true);
        config.setSecurityEnabled(false);
        config.getAcceptorConfigurations().add(new
TransportConfiguration(InVMAcceptorFactory.class.getName()));
        config.getConnectorConfigurations().put("connector", new
TransportConfiguration(InVMConnectorFactory.class.getName()));
        config.getAcceptorConfigurations().add(new
TransportConfiguration(NettyAcceptorFactory.class.getName(), params));
        ConnectionFactoryConfiguration cfConfig = new
ConnectionFactoryConfigurationImpl();
       
cfConfig.setName("cf").setHA(false).setConnectorNames(singletonList("connector")).setBindings("/cf");
        cfConfig.setClientFailureCheckPeriod(Long.MAX_VALUE);
        cfConfig.setConnectionTTL(-1);
        cfConfig.setReconnectAttempts(-1);
        cfConfig.setMinLargeMessageSize(250000);
        jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
        for (WorkQueue queue : WorkQueue.values()) {
            JMSQueueConfigurationImpl configuration = new
JMSQueueConfigurationImpl();
           
configuration.setName(queue.getName()).setSelector(null).setDurable(true).setBindings(queue.getQueuePath());
            jmsConfig.getQueueConfigurations().add(configuration);
        }

        AddressSettings addressSettings = new AddressSettings();
       
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
        addressSettings.setMaxSizeBytes(30 * 1024 * 1024);
        addressSettings.setPageSizeBytes(10 * 1024 * 1024);
        addressSettings.setPageCacheMaxSize(20);
        config.getAddressesSettings().put("jms.queue.*", addressSettings);

        EmbeddedJMS embeddedJMS = new EmbeddedJMS();
        embeddedJMS.setConfiguration(config);
        embeddedJMS.setJmsConfiguration(jmsConfig);


Here are how clients are connected: 

ConnectionFactory connectionFactory = (ConnectionFactory)
embeddedJMSserver.lookup("/cf");
javax.jms.Connection  consumerConnection =
connectionFactory.createConnection();
javax.jms.Connection  producerConnection =
connectionFactory.createConnection();

Session s = consumerConnection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
s.createConsumer(queue).setMessageListener(new DBCommandListener(this));

where DBCommandListener implements MessageListener. 

Also, when we had Hornet, it too was creating large messages.
To be honest, I'm less concerned about  creation of large messages, than the
fact that some messages are not processed until restart of process. 

tx



--
View this message in context: 
http://activemq.2283324.n4.nabble.com/ActiveMQ-does-not-send-some-messages-tp4706550p4706555.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to