Most Watched
Georgia U.S. Senate Special Election Debate
Incumbent Senator Kelly Loeffler (R-GA) and U.S. Senate Democratic candidate Raphael Warnock participate in a televised debate. The Atlanta Press Club and Georgia Public Broadcasting are sponsoring the event.
President Trump Campaigns for U.S. Senate Runoffs in Georgia
President Trump speaks at a rally in Valdosta, GA in support of Georgia Republican Senators David Perdue and Kelly Loeffler, both facing a runoff election in early January.
Washington Journal: News Headlines and Viewer Calls
Join us with your calls and comments on social media as we review the latest news headlines out of Washington.
Washington Journal: Cal Thomas Discusses President Trump's Legacy & Incoming Biden Administration
Author and conservative columnist Cal Thomas discusses President Trump’s legacy and the incoming Biden Administration.
Coming Soon
Hungary v. Simon Oral Argument
The U.S. Supreme Court hears the oral argument in Hungary v. Simon, Docket number 18-1447.
View More Supreme Court Oral ArgumentsGermany v. Philipp Oral Argument
The Supreme Court hears oral argument in Germany v. Philipp, a case on whether a group of German Jewish heirs can sue a German foundation in U.S. courts to get back or receive financial value for an art collection sold under duress in the 1930s.…
View More Supreme Court Oral ArgumentsFacebook, Inc v. Duguid Oral Argument
The Supreme Court hears oral argument in Facebook, Inc. v. Duguid, a case stemming from the social media company’s new log-in text alerts to users and whether they are unlawful under the Telephone Consumer Protection Act of 1991.
View More U.S. Supreme Court
Featured Clips
President Trump Claims He Won Georgia
Vice President Pence Urges Republican Voters to Check Registration, Request Absentee Ballots
Former President Obama Says Senators Perdue and Loeffler Downplayed Pandemic, Focused Instead on Stock Portfolios
Latest On
Former CIA Director John Brennan on National Security Threats
John Brennan, a former CIA director, discusses national security threats and priorities with the Center for Strategic & International Studies.
View AllGeorgia U.S. Senate Special Election Debate
Incumbent Senator Kelly Loeffler (R-GA) and U.S. Senate Democratic candidate Raphael Warnock participate in a televised debate. The Atlanta Press Club and Georgia Public Broadcasting are sponsoring the event.
View AllSenate Minority Whip Dick Durbin on COVID-19 Economic Relief Bill
On ABC’s “This Week,” Senate Minority Whip Dick Durbin (D-IL) talked about the prospects for a coronavirus pandemic economic relief bill getting passed before the end of 2020.
View All
In a publish/subscribe (pub/sub) product or application, clients address messages to a topic, which functions somewhat like a bulletin board. Subscribers can receive information, in the form of messages, from publishers. Topics retain messages only as long as it takes to distribute them to current subscribers.
C# (CSharp) ActiveMQ ConnectionFactory - 2 examples found. These are the top rated real world C# (CSharp) examples of ActiveMQ.ConnectionFactory extracted from open source projects. You can rate examples to help us improve the quality of examples. The C programming language provides a keyword called typedef, which you can use to give a type a new name. Following is an example to define a term BYTE for one-byte numbers − typedef unsigned char BYTE; After this type definition, the identifier BYTE can be used as an abbreviation for the type.
The following post introduces the basic concepts of JMS point-to-point messaging and illustrates them with a code sample using ActiveMQ and Maven.
Pub/sub messaging has the following characteristics:
- Each message can have multiple consumers.
- Publishers and subscribers have a timing dependency. A client that subscribes to a topic can consume only messages published after the client has created a subscription, and the subscriber must continue to be active in order for it to consume messages.
The JMS API relaxes this timing dependency mentioned in the second bullet to some extent by allowing subscribers to create durable subscriptions, which receive messages sent while the subscribers are not active. Durable subscriptions provide the flexibility and reliability of queues but still allow clients to send messages to many recipients.
Let’s illustrate the above characteristics by creating a message producer that sends a message containing a first and last name to a topic. In turn, a message consumer will read the message and transform it into a greeting. The code is very similar to the JMS Hello World example but contains a few key differences explained below.
Tools used:
- ActiveMQ 5.15
- Maven 3.5
The code is built and run using Maven. Specified below is the Maven POM file which contains the needed dependencies for Logback, JUnit and Apache ActiveMQ.
The Publisher
class contains a constructor which creates a message producer and needed connection and session objects. The sendName()
operation takes as input a first and last name which are set on a TextMessage
which in turn is sent to the topic set on the message producer.
The Subscriber
class contains a constructor which creates a message consumer and needed connection and session objects. The getGreeting()
operation reads a message from the topic and creates a greeting which is returned. A timeout
parameter is passed to assure that the method does not wait indefinitely for a message to arrive.
The below JUnit test class will be used to illustrate the Pub/Sub messaging characteristics mentioned at the beginning of this post. The testGreeting()
test case verifies the correct working of the getGreeting()
method of the Subscriber
class.
The testMultipleConsumers()
test case will verify that the same message can be read by multiple consumers. In order to test this, two Subscriber
instances are created on the same 'multipleconsumers.t' topic.
Finally, the testNonDurableSubscriber()
test case will illustrate the timing dependency between publisher and subscriber. First, a message is sent to a topic on which only one subscriber listens. Then a second subscriber is added to the same topic and a second message is sent. The result is that the second subscriber only receives the second message and not the first one whereas the first subscriber has received both messages.
Make sure a default ActiveMQ message broker is up and running, open a command prompt and execute following Maven command:
This will trigger Maven to run the above test cases which should result in the following log statements.
As mentioned in the beginning of this post it is also possible to create a durable subscription which allows receiving messages sent while the subscribers are not active.
Activemq C# Example
The JMS specification dictates that the identification of a specific durable subscription is done by a combination of the 'client ID', the 'durable subscription name' and the 'topic name'.
As a result of the below DurableSubscriber
has three main differences with the previous Subscriber
class:
- A
clientId
is mandatory on the connection in order to allow a JMS provider to uniquely identify a durable subscriber. - A durable subscriber is created using
Session.CreateDurableSubscriber
. - A
subscriptionName
is needed when creating the durable subscriber.
Note that creating a MessageConsumer
provides the same features as creating a TopicSubscriber
. The TopicSubscriber
is provided to support existing code.
The below JUnit test class will be used to illustrate the durable subscriber messaging characteristics.
It contains a testDurableSubscriber()
test case that will first remove one of the two durable subscribers that are listening on the 'durablesubscriber.t' topic by closing it’s connection to the broker. Then a first message is sent to this topic on which only one subscribers is still actively listening. The second subscriber is recreated using the same client ID and subscription name and a second message is sent. The expected result is that both subscribers receive the two messages.
Note that in the tearDownAfterClass()
method the durable subscriptions are removed in order to avoid an error when rerunning the test case.
Make sure a default ActiveMQ message broker is up and running, open a command prompt and execute following Maven command:
This will trigger Maven to run the above test cases which should result in the following log statements.
C&a Online Shop
If you would like to run the above code sample you can get the full source code here.
C# Activemq Topic Example
This concludes the JMS publish/subscribe example using ActiveMQ. If you found this post helpful or have any questions or remarks, please leave a comment.