Mixing protocols while using Apache ActiveMQ - jms

I am exploring ActiveMQ for advanced messaging between heterogeneous applications based on different technologies - C, Java, Ruby and Python. While looking at supported protocols I am stumbled to understand the use case of mixing protocols while performing message exchange. I had searched ActiveMQ documentation but unable to find any such reference talking about this.
My question is, say -
Producer (NewsPublisher) is publishing news(Sports, Finance, World) to a topic (NewsTopic) using AMQP. After publishing, this topic is storing these news under respective queues (Sports, Finance and World Queues) In this situation, a client subscribed to Sports queue is JMS based, another client subscribed to Finance queue is Stomp based; can these clients will be able to receive message available on the queue which was published using AMQP by NewPublisher?
I see a somewhat related question posted earlier however found answers unrelated to original question so thought to double check.

Mixing protocols in ActiveMQ is not all that hard, the broker takes care of all the internal routing and converting of messages from the incoming protocol to the outgoing bit so you don't have to worry to much about that.
What you do have to focus on is the common denominator of message types that your client mix allows you to use. In you question you've listed three different protocols AMQP, OpenWire, and STOMP (I'm guessing the JMS you are referring to is the ActiveMQ JMS client which uses OpenWire).
In this mix STOMP is the one to start with as it offers the least amount of options for message payload (Text and Binary) so you need to start there. Can you messages be restrained to those two domains? To send to STOMP from a JMS client then you can restrict yourself to a JMS TextMessage and or a JMS BytesMessage. In AMQP you will also need to restrict the message payload then to either a Text based payload for binary (think Data section containing a Binary wrapping an array of bytes).
ActiveMQ's STOMP protocol handler does offer some options to do Message transformations from other type such as converting a MapMessage into a JSON based string payload but it best to start simple and work your way up.
Given the breadth of the subject matter there a lot more that could be said, but this should help get you started. In short, yes you can mix clients on different protocols just fine in ActiveMQ but you do need to have some understanding of the limitations in doing so.

Related

Implementation of Message Bus C# microservices

We have few micro services created in .net core 1.0, we are following CQRS pattern and we are also using swagger which list all api's, we have a requirement were in we need to implement Message Bus(not decided yet might be AWS), this message bus will orchestrate UI operations, that spans across multiple backend services, so I don't know how to start because I 'm new to this, I need to understand message bus, queues, publishing events to message bus so could you please help me to understand?
Also any pointers to tutorial videos and so on with explanation would be helpful.
You would read this topic from Maira Wenzel at Microsoft. It helped me a lot on my beginning days.
An event bus allows publish/subscribe-style communication between microservices without requiring the components to explicitly be aware of each other
In a microservice architecture, Services should not communicate with each other in a synchronous way, instead, all services need to communicate via Message-Brocker. There are lots of messages brokers like RabbitMq, Kafka and so on which you can use them.
Using a message broker directly needs to manage all of the details related to message brokers' behaviors and need lots of code to do that. So here Service-Bus comes to the story.
The service bus is an intermediate between each service and message broker to encapsulate all details and configurations in the Message broker. So microservice blocks (each bounded context in DDD) could communicate with each other simply and in a high-level manner.
The point is in the service bus you just get rid of message broker complexities. So you don't need to worry about low-level concepts like the type of exchanges, queues, and so on in message broker.
I just have tried to give you high-level information, But in fact, Message Bus could do lots of other things.

Netty and Channels and Websockets

So, I have built a Netty 3.6.2 based Websockets server application. This application will have many, many users.
The idea is that clients register to listen for information on a topic, and when information flows through the server, the server sends the information to the clients. Sound straightforward so far, right?
I implemented this by building a giant map held in memory mapping the topic to the client's Channel. When the server wants to send a message about a topic too all interested clients, it loops over all channels mapped to that topic. Seem straightforward, right?
However, in some preliminary multi-user testing, I find myself realizing there is not a one-to-one mapping between channel and client. How do I specifically target sending a message to a particular client if not through the channel? I am at a loss....
There should be a one-one ratio of clients to open channels. The fact that there is not is some sort of issue that is not related to netty.
Thank you for your help.

Platform independent streams

We have two systems, one based on JMS and another based on WebSphere MQ.
There is client A which sends a message to a topic configured in JMS. Another client B which receives this message through the Topic configured in WebSphere MQ.
How can I make this communication happen? What are the considerations while building this bridge? If bridge is the solution, how can I build it?
I assume from your description that one of the clients is written in Java (JMS) and the other one is written in an other language and both have access to the same queue. MQ-Series is a queuing product, JMS is a Java API (like JDBC is to relational databases). MQ-Series supports the JMS API so there is no problem in communciating messages. JMS will probably be a subset of possible MQ-Series features.
Make sure that the content can be interpreted by both parties. The standard way is to use XML in the message. But you could use any other format that both clients can understand. You could also use CSV (comma separated values), JSON (JavaScript object notation) and there are even cross platform binary formats like Hessian.
But if you could be more specific about the participants and the kind of information you want to communicate, you probably would get more specific answers.

Which group messaging technology to use?

I feel a little bit kind of confused — for about 24 hours I have been thinking which group broadcasting technology to use in my project.
Basically, what I need is:
create groups (by some backend process)
broadcast messages by any client (1:N, N:N)
(potentially) direct messages (1:1)
(important) authenticate/authorize clients with my own backend (say, through some kind of HTTP API)
to be able to kick specific clients by backend process (or server plugin)
Here is what I will have:
Backend-related process(es) in either Ruby or Haxe
Frontend in JS+Haxe(Flash9) — in browser, so ideally communicating through 80/443, but not necessarily.
So, this technology will have to be easily accessible in Haxe for Flash and preferably Ruby.
I've been thinking about: RabbitMQ (or OpenAMQ), RabbitMQ+STOMP, ejabberd, ejabberd+BOSH, juggernaut (with a need to write a Haxe lib for it).
Any ideas/suggestions?
Yurii,
RabbitMQ, Haxe and as3: http://geekrelief.wordpress.com/2008/12/15/hxamqp-amqp-with-haxe/
RabbitMQ, Ruby and ACLs: http://pastie.org/pastes/368315
You might also want to look at using Nanite with RabbitMQ to manage backend groups: http://brainspl.at/articles/2008/10/11/merbcamp-keynote-and-introducing-nanite
You say you need:
* broadcast messages by any client (1:N, N:N)
* (potentially) direct messages (1:1)
You can easily do both using RabbitMQ. RabbitMQ supports both cases, 1:N pubsub and 1:1 messaging, with 'direct' exchanges.
The direct exchange pattern is as follows:
Any publisher (group member) sends a message to the broker with a 'routing key' such as "yurii". RabbitMQ matches this key with subscription bindings in the routing table (aka "exchange") for you. Each binding represents a subscription by a queue, expressing interest in messages with a given routing key. When the routing and binding keys match, the message is then routed to queues for subsequent consumption by clients (group members). This works for 1:N and 1:1 cases; with N:N building on 1:N.
Introduction to the routing model: http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/
General intro: http://google-ukdev.blogspot.com/2008/09/rabbitmq-tech-talk-at-google-london.html
You also require:
* (important) authenticate/authorize clients with my own backend (say, through some kind of HTTP API)
Please see the ACLs code for this (link above). There is also a HTTP interface to RabbitMQ but we have not yet combined the HTTP front end with the ACL code. That shouldn't hold oyu back though. Please come to the rabbitmq-discuss list where this topic has been talked about recently.
You also require:
* create groups (by some backend process)
* to be able to kick specific clients by backend process (or server plugin)
I suggest looking at how tools like Nanite and Workling do this. Group creation is not usually part of a messaging system, instead, in RabbitMQ, you create routing patterns using subscriptions. You can kick specific clients by sending messages to them by whichever key they have used to bind their consuming queue to the exchange.
Hope this helps!
alexis
If you are going to be doing Flash dev have you looked at SmartfoxServer? It has everything you want and has native Flash client libraries. I used in on a project to manage 10s of thousands of connected users.
http://www.smartfoxserver.com/
Well group communication is a slightly different beast than simple messaging / queuing.
Most group communication systems are commercial but there are two (that I know of) open-source / free you can take a look at:
Spread Toolkit
OpenAIS
Both of these might be tough to find Ruby bindings though. Spread, and probably OpenAIS, view clients as trusted so a browser based client doesn't make sense. You'd need to have your browser front-ends talk to a group client(s) on the back-end.
We've been using ActiveMQ. Our vendor who supplies our HR system is using Ruby/ActiveMQ to broadcast and receive updates.
http://activemq.apache.org/cross-language-clients.html
Other open source message brokers which support the Stomp protocol are OpenMQ, which is included in GlassFish V3 and GlassFish 2.1.1 but also works standalone, and soon the JBoss message broker, HornetQ V2.1.
OpenMQ supports temporary queues which are useful for a RPC style communication, but ActiveMQ offers some interesting features in the Stomp adapter too.

Tool for posting test messages onto a JMS queue? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Can anyone recommend a tool for quickly posting test messages onto a JMS queue?
Description:
The tool should allow the user to enter some data, perhaps an XML
payload, and then submit it to a queue.
I should be able to test consumer without producer.
This answer doesn't apply to all JMS brokers, but if you happen to be using Apache ActiveMQ, the web-based admin console (by default at http://localhost:8161/admin) allows you to manually send text messages to topics or queues. It's handy for debugging.
HermesJMS seems to be a rather powerful client for interacting with JMS providers. In my opinion, it is pretty unintuitive and hard to set up, though. (At least I'm mostly failing at it...)
Other, more user-friendly clients are often vendor-specific. Sonic Message Manager is a very nice and simple-to-use open-source JMS client for SonicMQ. It would be great to have a client like that working with different providers.
The ActiveMQ's web-based admin console has a big deficiency - one cannot specify any headers / custom properties when posting a message.
I came across a neat FOSS tool that can post a message and also specify headers/properties:
http://sourceforge.net/projects/activemqbrowser/
HTH
Apache JMeter is a tool (written for the Java platform) which allows:
sending messages to a queue ( point to point)
publishing/subscribing to a topic
sending both persistent and non persistent messages
sending text , map and object messages
Apache ActiveMQ includes a ProducerTool and a ConsumerTool example sources (Java) with many command-line configuration options. As it is based on the JMS API, using it with other message brokers should be easy with minor modifications.
IBM provide a free, powerful command line tool called perfharness.
Although aimed at benchmarking JMS providers, it's really good at generating (and consuming) test messages. You can use data either generated randomly or taken from a file.
The power features include sending and consuming messages at a fixed rate, using a specific number of threads, using either JMS or native MQ, etc. It generates statistics telling you exactly how fast your queue is performing (hence the name).
The only down side is that it's not super intuitive, given the number of operations it supports.
I recommend the approach of #Will and using the Web Console of ActiveMQ which lets you post messages and browse queues or delete messages easily.
Another approach I often use is to use a directory of files as sample data and use a Camel route to move the messages from the directory to a JMS queue - or to take them from a queue and save them to disk etc
e.g.
from("file://someDirectory").
to("activemq:MyQueue");
This would move all the files from someDirectory and send them to an ActiveMQ queue called MyQueue. If you'd rather leave the files in place you can use the URI "file://someDirectory?noop=true".
For more details see
the file endpoint in Camel
a sample Camel example routing from files to JMS
the various enterprise integration patterns Camel supports
Also if the JMS broker supports JMX like ActiveMQ does you can use JConsole to post message and do a lot more.
ActiveMQ has a web console for sending test messages (like mentioned above), but if your provider doesn't have this, it might be easiest to just write a console app/web page to post test messages. Sending a message in JMS isn't too hard, you might get the most benefit just writing your own test client.
If you can use Spring in Java, it has some really powerful utilities, check out the JmsTemplate.
I'm not aware of a simple client. I remember looking for one a long time ago when I researched different queue systems and trying JMS I couldn't find one then, and I couldn't find one now. One thing though - there are a ton of tutorials that get you started and you could do a simple form to achieve that.
Sorry to be not more helpful.
I have built a GUI tool for administering Open Source JMS Servers (Currently Activemq and Hornetq). It can send and receive messages and most of the usual stuff, as well as aggregate queues and topics into logical "groups".
Its a commercial product but the BETA is free and is fully functional.
try it out at http://www.rockeyesoftware.com/
For ActiveMQ the examples directory holds scripts. For Rubyists, look at example/ruby/stompcat.rb and catstomp.rb for subscribing and publishing.
I'm a brazilian developer and I made a Java program for Post HTTP and JMS Messages his available for download at: https://sites.google.com/site/felipeglino/softwares/posttool
In thath page you can found english instructions.

Resources