This article is a mirror article of machine translation, please click here to jump to the original article.

View: 216172|Reply: 69

[Console Program] .NET/C# ActiveMQ operation example [Source code]

  [Copy link]
Posted on 7/27/2017 1:19:10 PM | | | |

Summary of information about ActiveMQ and RabbitMQ
http://www.itsvse.com/thread-4659-1-1.html
(Source: Architect_Programmer)

Because the project needs some data to be pushed and received, because the amount of data is relatively large, about 3 million data a day

At the beginning, I used http post to submit data, but found that it was too slow, and the sending speed was much smaller than the receiving speed.

Therefore, if you want to use a long socket connection to push and receive data, write the socket server and client yourself, one is a waste of time, but it may not be done well

Finally, activemq is used to push and receive data

First, the producer code is as follows:



Consumer, there are two models:

1: Ordinary subscription, no need for persistent "subscription", that is, when connecting, you can receive messages, and you can't receive messages before connecting, using "CreateConsumer"
2: Persistent subscription, after connecting, you can receive data that has not been pushed before, using "CreateDurableConsumer"


Links to the introduction of CreateDurableConsumer:The hyperlink login is visible.

Create a non-shared persistent subscription on the specified topic if it doesn't already exist, and create a consumer on that persistent subscription. This method creates a persistent subscription without using a message selector, and the noLocal value is false.
The application uses a persistent subscription, and the application needs to receive all messages published on the topic, including messages published when there are no active consumers associated with it. The JMS provider keeps a record of this persistent subscription and ensures that all messages from the subject publisher will be retained until they are delivered to the consumer and confirmed by that persistent subscription until they have expired.

Persistent subscriptions continue to accumulate messages until they are deleted using the unsubscribe method.

This method can only be used with non-shared persistent subscriptions. Any persistent subscriptions created using this method will be unshared. This means that only one active (i.e., not closed) consumer can exist on the subscription at a time. The term "consumer" here denotes the TopicSubscriber, MessageConsumer, or JMSConsumer object in any client.

A non-shared persistent subscription is identified by a client-specified name and a client identifier that must be set. Applications that then want to create consumers on a non-shared persistent subscription must use the same client identifier.

If an unshared persistent subscription with the same name and client identifier already exists, and the same topic, message selector, and noLocal value are already specified, and no consumer is already active (i.e., not closed) on the persistent subscription, this method creates an existing durable subscription on the MessageConsumer.

If a non-shared persistent subscription with the same name and client identifier already exists, and there is a consumer on the persistent subscription that is already active (i.e., not closed), a JMSException will be thrown.

If there is already a non-shared persistent subscription with the same name and client identifier but a different subject, a message selector or noLocal value has been specified, and no consumer is already active (i.e. not closed) on the persistent subscription, then this is equivalent to unsubscribing (deleting) the old one and creating a new one.

Shared and non-shared persistent subscriptions may not have the same name and client identity. If a shared persistent subscription with the same name and client identifier already exists, a JMSException is thrown.

There is no limit to persistent subscriptions and shared non-persistent subscriptions with the same name and clientId. Such a subscription will be completely separate.

This method is the same as the corresponding createDurableSubscriber method, except that it returns a MessageConsumer instead of a TopicSubscriber to represent the consumer.

Parameter:
Themes - Non-temporary topic subscriptions
name - The name used to identify this subscription
Throw:
InvalidDestinationException - If an invalid topic is specified.
IllegalStateException - If the guest identifier is not set
JMSException -
If the session fails to create a non-shared persistent subscription and MessageConsumer due to some internal error
If a non-shared persistent subscription with the same name and client identifier already exists, and the consumer is already active
If a shared persistent subscription with the same name and client identifier already exists
Since:
JMS 2.0

IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal);

where messageSelector is the message selector; The noLocal flag is false by default, and when set to true, it restricts consumers from only receiving messages published by the same connection as themselves, which is only applicable to topics, not queues. name is the unique identity of the subscription topic, and this parameter needs to be set when you subscribe to a persistent subscription.

Activemq .net needs to reference package download:The hyperlink login is visible.

Full source code download:

Tourists, if you want to see the hidden content of this post, pleaseReply




Score

Number of participants1MB+1 Collapse reason
lxc1118 + 1 Very powerful!

See all ratings





Previous:Activemq user permission configuration
Next:Unknown: Input variables exceeded 1000. To increase the limit change max_inpu...
Posted on 1/16/2018 9:11:47 AM |
a5192142 Posted on 2017-10-20 11:46
RE: .net/c# activemq操作示例[源码] [修改]
Advanced mode

How to read the source code
Posted on 12/11/2019 11:49:26 AM |
The prescription method is troublesome,
Posted on 10/20/2017 11:46:30 AM |
RE: .net/c# activemq操作示例[源码] [修改]
Advanced mode
Posted on 8/16/2017 11:54:36 PM |
When using M2MQTT, the certificate is reported as an error
Posted on 8/17/2017 4:14:37 AM |
Now start tinkering with how to use MQTT for push
Posted on 8/17/2017 3:45:19 PM |
I think it should be good
Posted on 8/29/2017 10:40:38 AM |
Hope this helps
Posted on 8/29/2017 1:38:07 PM |
I hope it works
Posted on 9/14/2017 3:15:04 PM |
When I was young, I read poetry and books, and I went wherever I went
Posted on 9/25/2017 9:35:22 AM |
I've been looking for it for a long time, I hope this time it helps, thank you!
Posted on 9/25/2017 9:45:59 AM |
@小渣渣
     How to buy accessories!
Posted on 9/29/2017 4:35:28 PM |
Because after all, I am interested, and I come to find materials to learn and learn
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com