You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by HellKnight <he...@foxmail.com> on 2014/01/23 04:41:33 UTC
Can I delete a message from a queue in c# code ?
I want to set a unique guid for each message in message head , then if I want
, I could delete a specific message if I want to. Is there any api in NMS
could help me deleting the message ? I am using ActiveMQ 5.9.0 and NMS 1.6.1
Thanks in advance.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by artnaseef <ar...@artnaseef.com>.
Interesting problem. Storing the state of the task in ActiveMQ is not a good
fit - ActiveMQ is designed to move messages reliably, not guarantee delivery
of a message only if some application condition is met.
Thanks for the details.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676813.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by HellKnight <he...@foxmail.com>.
I have implemented my solution , However, as you mentioned, it's really
really painful , I suggest no one go IKVM path if they encounter similar
problem.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676802.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by HellKnight <he...@foxmail.com>.
Hi artnaseef. Thanks for your reply. The short answer is "Yes" , I want
more than one consumers getting the same message.
The long answer : the messages I sent is notifications for future work
in a workflow system. Everyone who is responsible for doing the work should
receive notifications , but if one of them finish the work , then all the
consumers should not receive the same notification the next time they
login/refresh.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676801.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by artnaseef <ar...@artnaseef.com>.
Do you ever want more than one consumer to receive a message? If not, what
you need is a single queue and let the consumers compete for messages.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676800.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by HellKnight <he...@foxmail.com>.
I have some consumers, each one has a unique queue on broker. Every message
will be send to each consumer,which means I will send the same message to
every existing queue on broker. And I use individual ack mode because I want
client app do some work to process the msg before ack it. And I want
persistent delivery mode.
So naturally I use durable pub/sub at first, but this mode do not support
individual ack mode. so I simply make every consumer has their own queue on
broker.
Here is the problem : if one message is acked by one consumer, I want
other consumers won't receive that message the next time they connect to the
broker. I find no api in NMS(I am using c#) that could help , so I am kind
of out of any idea, and come up with the IKVM/JMX solution.
Is there any simple way that would help ?
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676799.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by HellKnight <he...@foxmail.com>.
Hi Mr. Bish : the IKVM way did not work fine, and I can't come up with any
simple solution by now. Can you help me a little bit ? Here are my use case
:
the messages I sent are notifications for future work in a workflow
system. Everyone who is responsible for doing the work should receive
notifications , but if one of them have finished the work , then all the
consumers should not receive the same notification the next time they
login/refresh.
every user of the workflow system has a queue of their own in broker. So,
if anyone has finished a job , the client app should delete the
corresponding notification message in each queue(NOT the queue itself). Is
there any nms api could help me doing this ?
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4677756.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by Timothy Bish <ta...@gmail.com>.
On 01/23/2014 10:21 PM, HellKnight wrote:
> I read a related post at stackoverflow.com , and you said IKVM could help in
> this situation ,I want to write a java program that could delete specific
> message as I wanted and then convert it to a dll by IKVM ,do you think this
> solution worth trying ?
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676723.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
IF you have infinite time and resources then sure give it a try.
Otherwise you might want to look at what you are trying to do and see if
there something simpler that could be done. What is the use case you
are trying to solve?
--
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/
Re: Can I delete a message from a queue in c# code ?
Posted by HellKnight <he...@foxmail.com>.
I read a related post at stackoverflow.com , and you said IKVM could help in
this situation ,I want to write a java program that could delete specific
message as I wanted and then convert it to a dll by IKVM ,do you think this
solution worth trying ?
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676723.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by Timothy Bish <ta...@gmail.com>.
On 01/23/2014 09:27 PM, HellKnight wrote:
> Thanks for the reply. I think your solution will delete all the message from
> a queue when there is no active consumer. But I want to delete messages
> according to their unique ID (the ID is set by me ) , and I want to delete
> messages when there are active consumers. Is there a simple solution for me
> ?
> Actually I am getting a little worried, I did some search on
> stackoverflow.com and it seems that JMX api is my only option , but calling
> JMX api from .NET APP written in C# could be a little hard , is that right?
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676721.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Well sounds like about all you can do is create another consumer with a
selector and try and consume the messages in question that way.
--
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/
Re: Can I delete a message from a queue in c# code ?
Posted by HellKnight <he...@foxmail.com>.
Thanks for the reply. I think your solution will delete all the message from
a queue when there is no active consumer. But I want to delete messages
according to their unique ID (the ID is set by me ) , and I want to delete
messages when there are active consumers. Is there a simple solution for me
?
Actually I am getting a little worried, I did some search on
stackoverflow.com and it seems that JMX api is my only option , but calling
JMX api from .NET APP written in C# could be a little hard , is that right?
--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691p4676721.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Can I delete a message from a queue in c# code ?
Posted by Timothy Bish <ta...@gmail.com>.
On 01/22/2014 10:41 PM, HellKnight wrote:
> I want to set a unique guid for each message in message head , then if I want
> , I could delete a specific message if I want to. Is there any api in NMS
> could help me deleting the message ? I am using ActiveMQ 5.9.0 and NMS 1.6.1
> Thanks in advance.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Can-I-delete-a-message-from-a-queue-in-c-code-tp4676691.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Yes, although only if that destination has no active consumers. You can
do something like this:
protected static void DeleteDestination()
{
IConnectionFactory factory = new
ConnectionFactory(ReplaceEnvVar(connectionURI));
using (Connection connection = factory.CreateConnection()
as Connection)
{
using (ISession session = connection.CreateSession())
{
IQueue queue = session.GetQueue(testQueueName);
try
{
connection.DeleteDestination(queue);
}
catch
{
}
}
}
}
--
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/