Send a message on Graylog GELF UDP Input through a JAVA class - udp

I've this Graylog GELF UDP Input (image) and I need to send a message through a JAVA class.
The message isn't Log info, but is JSON.
Can you help me find a simple solution?
I already use Graylog with AMQP Input, but I would like to create an emergency solution in case RabbitMQ is not available.
Thanks

Related

How to publish byte array to the queue by using RabbitMQ management plugin?

As shown below, RabbitMQ management GUI can publish a message to the specific queue directly.
The consumer of this queue consumes the message with protobuf format, which means I should publish the byte array to the queue instead of string. I have tried to convert the protobuf bytes into a base64 string but failed, is possible to tell the RabbitMQ Management GUI to convert the base64 string into bytes or there is another way to publish byte array directly?
RabbitMQ Management GUI talk to RabbitMQ Server over HTTP (HTTP is a text transfer protocol), so it is impossible to send binary data directly by Management GUI.
RabbitMQ community provide a command line tool rabbitmq-perf-test wrapped RabbitMQ Java client, you can publish binary message with your Content-Type.
The server pays no attention to the Content-Type header; it just passes
it through. So make sure your client supports your Content-Type.
You can use any HTTP client like curl or Postman or anything else.
And just send HTTP POST request like this:
curl 'https://rabbitmq.host/api/exchanges/%2F/amq.default/publish'
--data-raw '{"payload_encoding":"base64","vhost":"/","name":"amq.default","properties":{"delivery_mode":2,"headers":{}},"routing_key":"YOUR QUEUE NAME HERE","delivery_mode":"2","payload":"THE BASE 64 PAYLOAD HERE","headers":{},"props":{}}'

How to use activemq wildcards for sending messages

I try to send message to multiple queues according this documentation ActiveMQ Wildcards. The idea is to send message to PRICE.> queue and receive them in queues PRICE.STOCK.NASDAQ.ORCL and PRICE.STOCK.NYSE.IBM (queues are created). But instead of forwarding messages to PRICE.STOCK.NASDAQ.ORCL and PRICE.STOCK.NYSE.IBM activemq create new queue PRICE.> that become this message.
I tried to send message with activemq admin tool (send mask) and spring boot application. Behavior is the same - message is placed in new created queue PRICE.>.Activemq was not additionally configured, I'm using configuration provided with activemq 5.15.7.
The feature is only supported for subscribers, you need to send to a specific named destination when publishing a message. You can use the Virtual Destinations feature of ActiveMQ to define a target destination that forwards to some defined set.

RabbitMQ - How to save message for new consumer

Working on a new chat project, We want to use RabbitMQ to transfer our message.
So can RabbitMQ save all the message in queue or some other place, when an new people(consumer) comes, the RabbitMQ can flush the saved message to the new people?
If you use a persistent queue, rabbitmq can store the messages (the messages are stored in the same mnesia-db path).
So suppose that each user has a own queue, when the user gets on line can download the messages.
Anyway I don’t think it is a good idea use rmq to push messages for chat. There are others appropriate technologies, like MQTT, XMPP.
I suggest to read this post:
using rabbitmq in android for chat
Please read the tutorial to understand what RabbitMQ is.
RabbitMQ is a message broker: it accepts and forwards messages. You can think about it as a post office: when you put the mail that you want posting in a post box, you can be sure that Mr. or Ms. Mailperson will eventually deliver the mail to your recipient. In this analogy, RabbitMQ is a post box, a post office and a postman.

Stomp ActiveMQ questions

I am new to Stomp ActiveMQ. I want to create a login from an android client and I don't know how to use ActiveMq. I\ve installed active mq, configured stomp and run the stompexample.
1. I have an error when running activemq from command line if I add in in the activemq.xml the following line:
<transportConnector name="stomp+nio" uri="stomp+nio://localhost:61612"/>
<transportConnector name="stomp+ssl" uri="stomp+ssl://localhost:61612"/>
Can someone please explain what is with tx1 and tx2? Is there a way to send on the queue a message to a specific client? how?
connection.connect("system", "manager");
connection.begin("tx1");
connection.send("/queue/test", "message1");
connection.send("/queue/test", "message2");
connection.commit("tx1");
connection.subscribe("/queue/test", Subscribe.AckModeValues.CLIENT);
connection.begin("tx2");
StompFrame message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
connection.commit("tx2");
connection.disconnect();
Can someone please tell me how to create an application that sends on a queue a text containing username, password and receives an answer if the register was successful?
You need to configure the transport connectors with different port numbers, they can't both share port 61612. Your configure is create a Stomp NIO connector and a different Stomp SSL Connector.
You can't send messages to a distinct client, you just place them on a Queue and if there is a client subscribed it will get the message, that's the nature of Queue based messaging. The TX1 TX2 stuff is sending the messages within a transaction.
Recommend you take some time to read up of JMS Messaging, the Stomp spec and some other messaging based tutorials.

How to set up Monitoring for queue in activemq

I read in ActiveMQ page, using JMX we can monitor queues in activemq. How can we get notified if a queue has messages (depth high) or service interval is high in ActiveMQ. Without using any shell scripts in unix environment. Is it possible through Java program? If yes, give me some ideas to get this done.
For a JMX-free approach, you can also use the XML feed served by the activemq console page. The XML feed is hosted at http://ip:port/admin/xml/queues.jsp
This will have tags similar to this for each queue:
<queue name="your queue">
<stats size="0" consumerCount="1" enqueueCount="0" dequeueCount="0"/>
....
</queue>
Just parse this XML in your code and you are good to go.
you can use Java via JMX APIs to periodically poll for queue stats (see this guide)
for the notification approach, you'd need to use advisory messages to monitor messages delivered to a queue (see this guide)
Yes it is possible in Java.
Starting from version 5.8 of ActiveMQ jolokia agent comes embedded. So it is possible for you to get all stats that JMX can pull using HTTP request which will retuen you stats as JSON and then you can check current values and raise Email alert using SMTP if values go beyond threshold you have decided.
Lets say you want to pull Broker stats using Jolokia hit below URL in your browser enter AMQ console username and password which is admin by default
http://servername.com:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost
Or if you dont want to go through all this trouble , You can use ready made Python script which I have created to Monitor AMQ Heap, Queue params and Broker availability.You can take a look , it may help you in developing your custiom script or program
AMQMonitor and Alerting script