You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by geen <gp...@curaspan.com> on 2014/01/09 18:57:45 UTC

Virtual Destinations with no consumers

Hi, 

I've created a virtual topic and configured the virtual destinations.  When
a new queue is created in accordance to the virtual topic naming, messages
will only get forwarded to these queues if there is an active consumer.  I
would like the messages to get forwarded to these queues even if no
consumer.  Is this possible? 

Thanks 
G



--
View this message in context: http://activemq.2283324.n4.nabble.com/Virtual-Destinations-with-no-consumers-tp4676173.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Virtual Destinations with no consumers

Posted by geen <gp...@curaspan.com>.
*We have some code that publishes message to a virtual topic. Here is the
publisher that publishes to the topic*

public void send(final CareEventDTO careEventDTO ){
		 
		 final long orgID = careEventDTO.getOrganizationToBeNotified();
		 jmsTemplateConnection.setDeliveryMode(DeliveryMode.PERSISTENT);
		 jmsTemplateConnection.setExplicitQosEnabled(true);
		 jmsTemplateConnection.setTimeToLive(20000);
		 jmsTemplateConnection.send(new MessageCreator()
		 {
				
				public Message createMessage(Session session) throws JMSException {
	            
					javax.jms.ObjectMessage objmsg =
session.createObjectMessage(careEventDTO);
					objmsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
				
					objmsg.setStringProperty(OrganizationProperyName,
String.valueOf(orgID));

	                return objmsg;
	            }
				
		 });
		 
	 }



*ON suscriber side we have an HTTP long poll request waiting for next
message on virtual destination queue. Once we get message we send message
back through http response.. we are closing session/connection on every
receipt of a new message.  When a new HTTP request happens(new long poll) we
listen again with new http long poll.  The time between web call is very
small but between this time there is no consumer on queue.  Messages get
lost between this time period.  Messages should still be sent to queue even
when subscriber isn't lisetning.

Here is Subscriber "getnextmessage" code...  
*

 

private List<CareEventDTO> getNextEventMessage(String destination, String
Selector)
            throws Exception {

        List<CareEventDTO> returnedEventList = new
ArrayList<CareEventDTO>();

      
        Connection conn = connectionFactory.createConnection();
        conn.start();

        Session session = conn.createSession(true,
Session.CLIENT_ACKNOWLEDGE);
      
        Queue myQueue = session.createQueue(destination);
        CareEventDTO careEvent;
        
        MessageConsumer mc = session.createConsumer(myQueue, Selector);
        
        ObjectMessage message = (ObjectMessage)
mc.receive(JMS_RECEIVE_TIMEOUT);

        try {
            if (message != null) {
                message.acknowledge();
                session.commit();
            }

            if (message != null) {
                careEvent = (CareEventDTO) message.getObject();
                returnedEventList.add(careEvent);
                
            }

        } finally {
            if (mc != null) {
                mc.close();
            }
            if (session != null) {
                session.close();
            }
            if (conn != null) {
                conn.stop();
                conn.close();
            }
        }
        return returnedEventList;
    }



--
View this message in context: http://activemq.2283324.n4.nabble.com/Virtual-Destinations-with-no-consumers-tp4676173p4676183.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Virtual Destinations with no consumers

Posted by Christian Posta <ch...@gmail.com>.
Show a test case that reproduces this.

On Thursday, January 9, 2014, geen wrote:

> That's what I thought but as soon as I disconnect the consumer from the
> queue.  Messages from the topic do not propagate to that queue. If I
> connect
> a consumer back I start receiving messages but the messages that occurred
> during disconnect are lost.
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Virtual-Destinations-with-no-consumers-tp4676173p4676179.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Virtual Destinations with no consumers

Posted by geen <gp...@curaspan.com>.
That's what I thought but as soon as I disconnect the consumer from the
queue.  Messages from the topic do not propagate to that queue. If I connect
a consumer back I start receiving messages but the messages that occurred
during disconnect are lost.  



--
View this message in context: http://activemq.2283324.n4.nabble.com/Virtual-Destinations-with-no-consumers-tp4676173p4676179.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Virtual Destinations with no consumers

Posted by Christian Posta <ch...@gmail.com>.
well, the messages will be sent to the queues if the consumer has
connected at least once.
when it does connect, the queue is created and then the consumer can
come and go (similar to a durable sub)

On Thu, Jan 9, 2014 at 9:57 AM, geen <gp...@curaspan.com> wrote:
> Hi,
>
> I've created a virtual topic and configured the virtual destinations.  When
> a new queue is created in accordance to the virtual topic naming, messages
> will only get forwarded to these queues if there is an active consumer.  I
> would like the messages to get forwarded to these queues even if no
> consumer.  Is this possible?
>
> Thanks
> G
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Virtual-Destinations-with-no-consumers-tp4676173.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



-- 
Christian Posta
http://www.christianposta.com/blog
twitter: @christianposta