How can I setup PRE_ACKNOWLEDGE mode using .NET Client application using AMQPNetLite - amqp

We are using a .NET Client using AMQPNetLite library to connect to ActiveMQ Artemis. I need to setup the pre-acknowledge mode and from the documentation, understood that this can be setup at the connector in broker.xml file. However, doing this didn't make any difference. It isn't very clear how to set this mode from the documentation.

The documentation you cited is for ActiveMQ Artemis clients using the native "core" protocol. It doesn't apply to the AMQPNetLite client. That client is developed in its own separate project which has its own documentation.
Also, for what it's worth, the documentation doesn't describe configuring pre-acknowledgement in broker.xml. It discusses configuring it on the client-side jndi.properties or programmatically via the JMS API. There is no way to configure pre-acknowledgement on the broker.
I recommend you take a look at "presettled" mode which is an AMQP semantic that should be essentially equivalent to pre-acknowdgement in ActiveMQ Artemis.

In terms of AMQP clients the idea of PRE-ACKNOWLEDGE mode would amount to creating the AMQP receiver link with the snd-settle-mode in the Attach frame to SETTLED so that the remote is informed that it should send your receiver deliveries that are already settled indicating the client wouldn't need to respond with a settled disposition itself as the remote has said it has already forgotten about the delivery.
As that relates to the AMQPNetLite you would be creating a ReceiverLink and giving it a custom defined Attach object with the settlement mode configuration you want which would like something like the below although you will need to test and tweak as needed.
Attach attach = new Attach();
attach.SndSettleMode = SndSettleMode.SETTLED;
attach.RcvSettleMode = RcvSettleMode.FIRST;
ReceiverLink receiver = new ReceiverLink(session, address, attach, onAttached);
Information about link establishment and Attach options can be found in the AMQP 1.0 specification.

Related

ActiveMQ - Stomp over websockets - Same Origin Policy

I have a process that runs in California that wants to talk to a process in New York, using Stomp over Websockets.
Also note that my process is not a web app, but I implemented a stomp over websocket client in C++, in order to connect things up to my backend. Maybe this was or wasn't a good idea. So, I want my client to talk to the server and subscribe, where their client pushed messages.
I was implementing my own server when I saw that ApacheMQ supported Stomp over Websockets. So, I started reading the docs.
It says with the last line under 'configuration' at
http://activemq.apache.org/websockets :
One thing worth noting is that web sockets (just as Ajax) implements ? > the same origin policy, so you can access only brokers running on the > same host as the web application running the client.
it says it again in several related searches such as http://sensatic.net/activemq/activemq-54-stomp-over-web-sockets.html
Is this a limitation of the server or the web client?
With that limitation, if I understand right, the server is not going to accept websocket connections from a client, of any kind, that is not on the same machine?
I am not sure I see the point of that...
If that is indeed its meaning, then how do I get around it in order to implement my scenario?
I've not found that bit of documentation you are referring to but from what I know of the STOMP implementation on the broker this seems incorrect. There shouldn't be any limit to the transport connector accepting connect requests from an outside host by default and I don't think the browser treats the websocket requests the same as it does other things like an Ajax case in terms of the same origin policy.
This probably a case that is best checked by actually trying it to see if it works, I've connected just fine from outside the same host using AMQP over websockets on ActiveMQ so I'd guess the STOMP stack should also work fine.

What are the available options when developing a decoupled, high scalable web application with server pushed events?

I would like to see if someone can clarify me some concepts I still don´t get about integration of web applications. Up until now, I´ve been working with CometD and Activemq in a project that´s been there for several years but, for what I´ve seen, there are other options out there much more simpler and supported by the community but I still don´t get the whole picture of options available.
So, for what I understand, at the moment, the most common way of getting server pushed events to a client is using websockets. The implementation is server specific and the most used one seems to be the Jetty one. But, because it requires a websocket compatible browser, there are some frameworks that are able to provide websockets and fall to reverse ajax techniques in case this is not an option, like SockJS, that has an implementation for client and for server side. Based on this, as of spring 4 there are templates that allow you to use SockJS behind the scenes and just provide the client implementation of the code using SockJS and letting the programmer to handle the server side in a more easy way.
Apart from this, brokers can understand the websocket protocol so a broker can receive a message from a web browser and then send a message back directly. There is also the STOMP protocol that brokers also implement that allows the system to send/receive messages through websocket to/from the web browser.
One question I have about this is, is STOMP the protocol always used by the broker to send or receive a message to or from a web browser? Or is just one alternative? What is the difference if it´s the later?
Yet another option I´ve seen is using a framework like camel. In this case, the web browser would talk to the websocket component of camel and from there it could be routed directly to the broker using jms. The benefit I see on this is the possibility of introducing processors as part of the route from the browser to the broker, allowing further security processing and reducing the traffic the broker would have to handle in case of not valid/unauthorized messages. Camel would even be able to listen to messages using the STOMP component what would be yet another routing option.
So, to this point, I don´t know if my understanding is correct or if I miss or misunderstand something. If everything is right, it seems that using a framework like SockJS is the best option available at the moment. The use of Spring 4 to simplify things is an option but not really necessary. If the project requires the integration of different systems using a jms broker, the implementation then falls to use SockJS to send messages to the server side and then just route the messages to the correct system. But at this point, there are the options mentioned before like using camel to route the messages or directly send messages to the broker. What would be the best option, or what would be the differences? If I add STOMP to the problem, what does this protocol give me that I can´t handle just with websockets or camel?
I hope I made myself clear. I think this topic includes several technologies and frameworks and it´s quite difficult to express all my concerns without extending the post to much.
Thanks in advance.
In a nutshell, if you want messaging semantics, you should use a messaging protocol such as STOMP. WebSockets sure can handle communication to browsers just fine, but that's just "any custom communication".
The system design may be cleaner if you design around the convention of topics and messaging. The server backend processes can easily push data to a topic that is propagated to all clients, ideally with no further customization.
Aside from STOMP, there is a similar protocol, MQTT which also can run over websockets. A chat demo is provided by ActiveMQ distribution. MQTT is very hot in the Machine2Machine world "internet of things", but I have used it with success in web-deployments too. MQTT should, at least in theory, run pretty good, with low overhead in phone apps, should you ever consider writing one side by side with your website. Then it can be good to use a single setup to communicate "push" data with your clients. Otherwise, your app may have used MQTT, your browser app would have used plain websocket, your backend would have needed another way to pass async events to clients (via some Camel router or similar) and so forth.

How can I test a program which publishes to Websphere MQ

I have a program which publishes data to IBM Websphere MQ via the MQAX200 interface. I'm struggling to work out how to test it.
What's the simplest way of setting up an application to consume the messages from the queue and confirm they're correct? I don't currently have any MQ infrastructure here (that's on the client's site).
Do I need a message broker? Are there any open source implementations? Or do i need to purchase Websphere MQ, in which case what's the minimal license I'd require?
Thanks
Ben
As your application is written using a MQ interface, you need MQ to test. If it's just for testing, you can use the trial version of MQ.
As far as I know MQAX200 interface supports only P2P messaging and not Publish/Subscribe messaging. So using your application put message to a queue and then use the application like amqsgetto receive message.
You don't need message broker.
First, you need to clarify what it is you are trying to do. If you are publishing messages then your test program will need to subscribe. If you are putting messages into a queue then your test program will need to GET messages from the same queue.
The WMQ Trial Download will get you a 90-day WMQ license for no charge. The trial code includes the server and the client libraries so you can set up a QMgr and then test your program in client or bindings mode, as appropriate. If you elect to install the sample code you also get compiled binaries with which you can test. For example, amqsget gets messages and amqssub subscribes to topics, both using bindings mode (shared memory). The client versions of these (amqsgetc and amqssubc) attach over the network. If you are using topics, make sure to subscribe before you publish. If using queues, make sure to GET after you PUT.
Other useful programs include amqsgbr to browse messages on queues and amqsbcg which will hex-dump the messages and parse the message headers. Also, WMQ Explorer comes with the Windows and Linux versions of the trial and you can use that to browse, subscribe or get messages.
Just write a simple Java JMS program that subscribes to the Topic. THen you only need to install the free WebSphere MQ Client.
This article is a bit old but should do.

Sending message to ActiveMQ over internet

I want to implement messaging over internet. But didn't have IP Public yet.
So I want to ask any one here about sending message to ActiveMQ using JMS over internet?
Could It be done ?
Yes, it exposes a normal TCP based endpoint(by default at port 61616). However, this would not be a recommended deployment model - a better model will be to expose a http based endpoint using a servlet container which internally hands over the message to the activemq broker.
There a lot of good solutions that can do this -
Spring Integration , Apache Camel
Exposing a Webservice endpoint using say Apache CXF (which will bring you a standards based interface), which will internally hand over the message to ActiveMQ.
yes, It can be done. we are currently running a little under a thousand "consumers" which connect to our brokers over the internet.
As to the insecurity of traffic over the internet, i do not agree completely:
exposing a webservice is just as riskfull as exposing the broker. In the end, you are never 100% sure your own code or the code or the underlying application (Apache CXF, Webserver, application server, database server, message broker) contain flaws that could be a security risk. Second to that, HTTP is just as much TCP traffic as ActiveMQ is ( Stomp or openwire protocol)
That being said, you can take all measures to make the risk as small as possible.
we have done the following:
User & Password Required to connect to the broker (ActiveMQ suports a wide range of Authentication solutions and you can roll your own if required)
Switch port to a different number so detection is more difficult
if you have control over the consumers aswell, apply IP filters in the firewall for what ip's can connect to the broker ( unfortunately, this was not possible in our case)
encrypt your messages
We have added an application level Authentication aswell using a token. This way, every message is authenticated in our own application
-> if all of these are implemented, I think you are pretty safe and as a bonus, you do not need the extra layer of webservices ( if this application needs to scale, you will need to scale your webservices equally with your brokers.
Plain connections (openwire) should be fine. It's much simpler to stick with the standard setup than to try setting up web services and whatnot. Just make sure to encrypt the channels with SSL. If you use plain passwords, they can possibly be picked up over public networks (unlikely but anyway) - that's why I prefer SSL.
Actually, ActiveMQ is a very good way to do communication over the Internet since it supports transactions and persistence, making it cope well with network stability issues.
However, you need a public IP (or some NAT/port forwarding solution form a public IP) on the machine running the ActiveMQ server for this to work.

How to create a messaging service?

I want to create a messaging service that uses the XMPP protocol. How would I implement the server-side as well as the client side aspects of this service? I know I would need a server (like Jabberd 2) that runs the messaging framework. How hard would this be to set up and get running? Also what would be the best way to hook up a client program into this service? How would i start pushing messages from one client, through the server, to another client?
Server: there are many out there, see http://xmpp.org/software/servers.shtml for a list.
I've used OpenFire in the past, it's fairly straightforward to set up.
You can add a library like xmppframework to your Cocoa project to make it a client, and configure it to talk to your XMPP server.
Each client gets an identifier (called a 'jid') of the form: uniquetext#xmppserver.name, and you send messages from one client to the other by addressing them to the jid of the intended recipient.
If you want to play around with simple examples in a scripting language, you can use something like the examples in the python xmpp library to see how it all works. Use an xmpp client like psi to connect as one jid and use the examples to connect as another jid to send/receive messages through the server.

Resources