I am queuing some messages with a scheduled delivery feature implemented in JBoss 3.2.2. Now If I want to cancel/remove a particular message before it get consumed is it possible me to remove that from the queue?

This is not what I suggested. To remove the message you have to identify, right? Otherwise how can you say 'I want to remove that message because the client wants to cancel something''.

I wasn"t saying 'check the ID and say do not activate. I was saying "please JMS give the message ID blablabla' and instead of doing something with it, just forget about it and close the session (that will have as effect that the message will be removed from the queue).

I don't understand why this concept is so difficult to understand. If you want to remove A message, you need a way to identify it, right? So you need, either the JMSMessageID, either your own ID mechanism, put as a JMS header (see my previous link for full details).

Can you please post an example that you have already worked out with MDB.-----------------

If you have a queue with orders and MDB connected on it. And if you want to cancel an order (that is remove a message) like this, it has basically no sense. Except when you server is highly loaded, the message will be processed almost immediatly. What's the purpose of cancelling an order if you need to do it in the next 5 seconds?

But I cannot agree with this for Scheduled Delivery.Since there may be a possibility of deleting messages before it got received?.

>But I cannot agree with this for Scheduled Delivery.>Since there may be a possibility of deleting >messages before it got received?.

Schedule delivery is just a message sitting in the queue and waiting for the delivery time. If you want to cancel this message, just 'receive' it manually. That is create a receiver to receive only that message (using a selector) and that 's it.

> Can you please post an example that you have already worked out with MDB.

Mmmm I start understanding why you do not understand ... Your MDB is there to get fired with a message (let's say in 7 days). If some component before that period consume the message, your mdb will not be fired (so your component cancel the message, right?)

What you need is a Session Bean that creates a receiver and the receive and consume that message. (see code snipper above - JmsReceiverSessionBean is a bean that can fetch data in a queue using a selector).