Messages are pending because a client has gotten them, but not yet acknowledged. I guess it's the client that should be looked into further.
If the client uses a configured connectionfactory (other then the default one), you can set the time-to-live override property on that. It can be set on the queue/topic as well. You could try that.
But, again, it's actually a signal that the consumer is not handling them properly.
Thanks for the reply.
Is the solution of setting time-to-live property would act on the messages that are in pending state from long time and how can we delete them ?
No, I think not. It applies to new messages. Can you stop the consumers?
Then the connections get lost and the messages might get visible again.