You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by bravegag <br...@hotmail.com> on 2009/10/22 19:00:22 UTC

hacking 5.2.0 TopicSubsciption but can't get hold of the Session

hi all,

I was previously asking how to extend the constant message pending limit
strategy to  send a custom "discarded" message to the replyTo field of the
old message before discarding it so a blocked sender can be released. This
architecture in general does not make much sense on top of JMS ... blocking
etc but this is a school benchmarking assignment ...

The code below is copied from 5.2 TopicSubscription.java line #116 I am
hacking to support such notify "discarded feature".

The only problem I have is that I don't know where to get the session from
to generate such reply "discarded" message ... any ideas? have been browsing
all the members etc but no clue where to get it from ...

Thanks in advance,
Best regards,
Giovanni
 // hack hack hack hack
 // hack hack hack hack
 // hack hack hack hack	                                
 if (oldMessage instanceof TextMessage) {
    TextMessage textMessage = (TextMessage) oldMessage;
    Destination destination = (Destination) textMessage.getJMSReplyTo();
    if (destination != null) {
       // Setup a message producer to respond to messages from clients, we
will get the destination
       // to send to from the JMSReplyTo header field from a Message
       MessageProducer replyProducer = session.createProducer(null);
		                                         
       replyProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);	                                	
		                                	
       TextMessage response = session.createTextMessage();  
       response.setText("DISCARDED");
		                                    
       replyProducer.send(response);	                                    
       replyProducer.close();	                                		
}	                                	
}
	                                
// after notifying then discard
discard(oldMessage);

-- 
View this message in context: http://www.nabble.com/hacking-5.2.0-TopicSubsciption-but-can%27t-get-hold-of-the-Session-tp26013589p26013589.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: hacking 5.2.0 TopicSubsciption but can't get hold of the Session

Posted by Gary Tully <ga...@gmail.com>.
have a look at
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/plugin/StatisticsBroker.java?view=markupfrom
trunk. It sends a message to the replyTo using internal broker apis.

2009/10/22 bravegag <br...@hotmail.com>

>
> hi all,
>
> I was previously asking how to extend the constant message pending limit
> strategy to  send a custom "discarded" message to the replyTo field of the
> old message before discarding it so a blocked sender can be released. This
> architecture in general does not make much sense on top of JMS ... blocking
> etc but this is a school benchmarking assignment ...
>
> The code below is copied from 5.2 TopicSubscription.java line #116 I am
> hacking to support such notify "discarded feature".
>
> The only problem I have is that I don't know where to get the session from
> to generate such reply "discarded" message ... any ideas? have been
> browsing
> all the members etc but no clue where to get it from ...
>
> Thanks in advance,
> Best regards,
> Giovanni
>  // hack hack hack hack
>  // hack hack hack hack
>  // hack hack hack hack
>  if (oldMessage instanceof TextMessage) {
>    TextMessage textMessage = (TextMessage) oldMessage;
>    Destination destination = (Destination) textMessage.getJMSReplyTo();
>    if (destination != null) {
>       // Setup a message producer to respond to messages from clients, we
> will get the destination
>       // to send to from the JMSReplyTo header field from a Message
>       MessageProducer replyProducer = session.createProducer(null);
>
>       replyProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
>       TextMessage response = session.createTextMessage();
>       response.setText("DISCARDED");
>
>       replyProducer.send(response);
>       replyProducer.close();
> }
> }
>
> // after notifying then discard
> discard(oldMessage);
>
> --
> View this message in context:
> http://www.nabble.com/hacking-5.2.0-TopicSubsciption-but-can%27t-get-hold-of-the-Session-tp26013589p26013589.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com