Apache Artemis listMessages MBean operation always returns nothing - jmx

I discovered MBeans recently and just checked out the ActiveMQ Artemis MBeans. Inside the queue attributes we see that there are some messages since the MessageCount is > 0.
But when I call the listMessages/AsJSON method the returned String is always empty:
Is there maybe I config I have missed? Other operations like listMessageCounter are working fine.

The issue is that the messages are "in delivery" which means that they will not be returned by the listMessages or listMessagesAsJSON methods. Notice that DeliveringCount is 16 (i.e. the same as Message Count). Messages which are in delivery are those messages which have been dispatched from the broker to a client but the client has not yet acknowledged.
Try using listDeliveringMessages or listDeliveringMessagesAsJSON instead.

Related

Posting byte message in solace queue through jmeter

Need to post a byte message to solace queue using Jmeter. I have tried in following manner might be am incorrect but tried with following:
Use JMSPublisher sampler
create jndi.properties file and put in jmeter/lib
jndi.properties
java.naming.factory.initial = com.solacesystems.jndi.SolJNDIInitialContextFactory
java.naming.provider.url = smf://<remote IP and port>
java.naming.security.principal=<username>
java.naming.security.credentials=<password>
Solace_JMS_VPN=<VPN Name>
in JMSPublisher sampler (in GUI)
Connection Factory = connectionFactory
Destination = (Queue Name )
Message Type (radio button---Byte message)
Content encoding -- RAW
in text area ---> (Byte message)
Note : I have used actual values of IP/port/username/port/queuename/bytemessage, cannot share those. Soljms jar is available in lib folder too.
getting error :
Response message: javax.naming.NamingException: JNDI lookup failed - 503: Service Unavailable [Root exception is (null) com.solacesystems.jcsmp.JCSMPErrorResponseException: 503: Service Unavailable]
Though it is working perfectly fine when did with java spring boot. There used properties files in place of JNDI.
It would be great if anyone can guide me , please do not give activeMQ JNDI am actively looking for posting on solace queue or create connection to solace appliances through Jmeter.
I don't think you should be putting your Byte message into the textarea as it accepts either plain text or an XStream object, consider providing your payload via binary file(s) instead
If you're capable of sending the message using Java code you should be able to replicate the same using:
JMeter's JSR223 Sampler with Groovy language (Java syntax will work)
Or JUnit Request sampler if you need "strict" java

Mirth Connect HTTP Listener Mapping Response ACK message

We are trying to merge two Mirth servers. One server (let's call it Server 1) is keeping all records and another server (Server 2) is getting HL7 message from the first one and writes messages to the database.
Everything was perfect so far. But Server 1, after sending each HL7 message, waits for ACK to consider this transaction as completed and to send another message from the list.
The success status coming from the Server 2 (which writes to the database) contains MySQL response such as "Success: Database write success. 1 rows updated.". This is not what Server 1 is expecting.
Therefore, the Server 1 considers this ACK as invalid, produces an error "Message Read Error - Will Retry" and keeps trying to send the same message again, causing Server 2 to duplicate messages in the database.
We are using Mirth Connect HTTP listener and we could not find any solution to send ACK msg to our first server the same screen HTTP listener.
Is there any way to do this? Any Suggestion?
Really need help.
The problem is you are not setting the response from server 2 correctly, so it just returns what the destination has. You can create an ACK by code on the destination transformer:
var ackMessage = ACKGenerator.generateAckResponse(connectorMessage.getRawData(), "AA", "Message Successfully Received");
responseMap.put("ackresp", ResponseFactory.getSentResponse(ackMessage));
And on your source connector select "ackresp" as response. Your server 1 will receive that ACK instead of the log of the database write.

Connection in RabbitMQ server auto lost after 600s

I'm using rabbitMQ server with amq.
I am having a difficult problem. After leaving the server alone for about 10 min, the connection is lost.
What could be causing this?
If you look at the Erlang client documentation http://www.rabbitmq.com/erlang-client-user-guide.html you will see a section titled Connecting To A Broker
This gives you a few different options that you can specify when setting up your connection to the RabbitMQ server, one of the options is the heartbeat, as you can see the default is 0 so no heartbeat is specified.
I don't know the exact Erlang notation, but you will need to do something like:
{ok, Connection} = amqp_connection:start(#amqp_params_network{heartbeat = 5})
The heartbeat timeout is specified in seconds. So this would cause your consumer to heartbeat back to the server every 5seconds.
Also take a look at this discussion: https://groups.google.com/forum/?fromgroups=#!topic/rabbitmq-discuss/u227xzvqOr8
The default connection timeout for the RabbitMQ connection factory is 600 seconds (at least in the Java client API), hence your 10 minutes. You can change this by specifying to the connection factory your timeout of choice.
It is good practice to ensure your connection is release and recreated after a specific amount of time, to prevent eventual leaks and excessive resournces. Your code should ensure that it seeks a valid connection that is not close to be timed-out, and re-establish a new connection on the ones that did time-out. Overall, adopt a connection-pooling approach.
- Java example:
ConnectionFactory factory = new ConnectionFactory();
factory.setHost(this.serverName);
factory.setPort(this.serverPort);
factory.setUsername(this.userName);
factory.setPassword(this.userPassword);
factory.setConnectionTimeout( YOUR-TIMEOUT-IN-SECONDS );
Connection = factory.newConnection();

How do I handle a WebSocket close from the client in Yaws?

I have implemented a simple appmod that handle WebSockets and echo back the messages. But how do I handle an ws.close(); from the JavaScript client? I have tried with the code below, but handle_message({close, Reason}) is never called and ws.onclose = function(evt) {} is never executed on the JavaScript client.
When I use the same JavaScript client code interacting with a node.js websocket, the client receives an onclose event immediately after ws.close();.
Here is the code for my simple appmod:
-module(mywebsocket).
-export([handle_message/1]).
handle_message({text, Message}) ->
{reply, {text, <<Message/binary>>}};
handle_message({close, Reason}) ->
io:format("User closed websocket.~n", []),
{close, normal}.
Updated answer:
As of github commit 16834c, which will eventually be part of Yaws 1.93, Yaws passes a new callback to your WebSockets callback module when the client sends a close message. The callback is:
{close, Status, Reason}
where Status is either the close status sent by the client, or the numerical value 1000 (specified by RFC 6455 for a normal close) if the client didn't include a status value. Reason is a binary holding any optional reason string passed from the client; it will be an empty binary if the client sent no reason.
Your callback handler for a close message MUST return {close, CloseReason} where CloseReason is either the atom normal for a normal close (which results in the status code 1000 being returned to the client) or another legal numerical status code allowed by RFC 6455. Note that CloseReason is unrelated to any Reason value passed by the client. Technically CloseReason can also be any other Erlang term, in which case Yaws returns status 1000 and passes the term to erlang:exit/1 to exit the Erlang process handling the web socket, but based on RFC 6455 we suggest simply returning the atom normal for CloseReason in all cases.
Original answer, obsoleted by Yaws github commit 16834c:
Yaws never passes a {close, Reason} message to your callback module. Rather, {close, Reason} is a valid return value from handle_message/1 should your callback module decide it wants to close the ws socket.
I modified the websockets_example.yaws file shipped with Yaws (version 1.92) to call this._ws.close() in the client if the user enters the "bye" message on the web page, and added an alert to the _onclose function to show that the onclose event is triggered. In this case the alert occurred, I believe because the "bye" message causes the server to close the ws socket explicitly. But I then modified the example to call this._ws.close() in the client no matter what message the user enters, and in that case no alert for onclose occurred. In this case, a check with lsof showed the ws connection from the browser to Yaws was still present.
So, for now I believe you've hit a bug where the Yaws websockets support isn't detecting the client close and closing its end. I'll see if I can fix it.

Indy's TIdHTTPProxyServer: How to filter requests?

I'm using an TIdHTTPProxyServer to implement a simple HTTP proxy, but I'd like now to block some connections if they match certain URLs. Which event and/or component is best to accomplish that? Indy documentation is not too explicative. :(
Thanks!
As a basic filter you can use the OnHTTPBeforeCommand event handler (which fires before the command is sent to the HTTP server).
Inspect the Context parameter properties, you'll find useful:
Context.Command
Context.OutboundClient.Host
Context.OutboundClient.Port
Context.Document
Context.Headers
I never tried to stop the PassTrough at this time, but I bet you can do it by just raising an exception at that point if you determine there's a block rule match.
the component has a "OnConnect" event, double-click it and add this code:
if AContext.Connection.Socket.Binding.PeerIP = '127.0.0.1' then
AContext.Connection.Disconnect;
replace 127.0.0.1 with your filter, this is just a "extremely basic example", same applies to other Indy servers which have a "OnConnect" event.

Resources