Java application with azure service bus - java

I have an audit service. other application will call that service for auditing purpose. my concern is all call to audit service to be queued in azure service bus to make sure fault tolerance.please help me with how to queue other service call to audit service.

Now that you already have considered using service bus, there is no concern about fault tolerance. That's the exactly feature of Azure Service Bus.
Let the other services send message to the queues and your audit service receive those messages to consume them in the order.
You could create queues using the Azure portal, PowerShell, CLI, or Resource Manager templates. You then send and receive messages using a QueueClient object.
To quickly learn how to create a queue, then send and receive messages to and from the queue, see the quickstarts for each method. For a more in-depth tutorial on how to use queues, see Get started with Service Bus queues.
For a working sample, see the BasicSendReceiveUsingQueueClient sample on GitHub.
Then if you concern fault tolerance about audit service,you could use ReceiveAndDelete mode. ReceiveAndDelete mode is the simplest model and works best for scenarios in which the application can tolerate not processing a message if a failure occurs.More details, please refer to this link.

Related

Is it possible to create a JmsListener for a specific Session in Spring Boot JMS with Azure Service Bus

I have a Service Bus Queue which is Session-enabled. For example, let's say that messages are divided into Session-1 and Session-2 in the queue.
I am trying to create two JmsListeners for the queue, one processing messages with Session-1 and another for Session-2.
In the Azure documentation for using Spring Boot with a Service Bus Queue I see that there is an example of how to set the Session ID while sending a message via JMSXGroupID, however there is no example on how to receive messages for a particular session.
My only idea at the moment is to use a MessageSelector to filter.
It looks like it is not possible as of now, see this Github issue.

How to continuously pull messages from service bus queue by using spring boot java application

How to continuously pull messages from service bus queue. Like in aws we have :
spring-cloud-starter-aws-messaging
and a : Link to explain more
How to do similar thing in azure?
Same you can do in Azure as well.
You can create queues using the Azure portal, PowerShell, CLI, or Resource Manager templates. Then, send and receive messages using clients written in C#, Java, Python, and JavaScript.
Receive messages from a queue
Add a method named receiveMessages to receive messages from the queue.
This method creates a ServiceBusProcessorClient for the queue by
specifying a handler for processing messages and another one for
handling errors. Then, it starts the processor, waits for few seconds,
prints the messages that are received, and then stops and closes the
processor
For more information you can refer this MS Document for Create a console project and Configure your application to use Service Bus

how to send and consume messages in Event hub via rest api

I am new to the Azure EventHub. I wanted to write a simple prototype which can send and receive messages from AzureEventHub via its rest api.
Could you please help me by providing code snippet demonstrating how to use rest api exposed in EventHub for message producing and consuming.
Sorry, im not sure if there is any java examples around be here are a few links that might help:
Here is a little article that explains how you can generate a SasKey (Shared Access Signature). you to send this key along with every request.
http://www.mikelanzetta.com/2014/09/talking-to-eventhub-from-node/
There is a (unofficial) Azure Service Bus JavaScript SDK, maybe this illustrates how its working
It provides following artefacts:
QueueClient
Topic Client
SubscriptionClient
EventHubClient
Here is an article about sending data to an EventHub: using the javascript sdk.
http://developers.de/blogs/damir_dobric/archive/2015/01/26/eventhubs-support-for-azure-servicebus-javascript-sdk.aspx
I'm the (co-)author of https://github.com/noodlefrenzy/node-amqp10 and can verify that there is no RESTful way to consume messages from an Event Hub - you need to use AMQP. There is a JMS binding for AMQP via Qpid-Proton that you can use.
This article https://azure.microsoft.com/en-gb/documentation/articles/service-bus-java-how-to-use-jms-api-amqp/ has details for using it with Service Bus, but it should be similar for Event Hubs. The main difference with Event Hubs is that messages are never "consumed" and come through on several "partitions", so you would need to connect to all of your partitions, and store the offsets as messages come in so you can specify those when you reconnect.
As per my understanding about EVENTHUB, Rest API has been exposed to send data and there are no rest api available to receive data from event hub.
I tried implementing Receiver for event hub using
1. in Java using https://github.com/hdinsight/eventhubs-client
2. In nodejs using https://github.com/noodlefrenzy/node-amqp10

Throttling an AMQP Consumer Using RabbitMQ

I'm using AMQP in a reliability pattern and my use-case is to put messages in a queue, then consume them and insert the information into a web service. My web service is slow, and my queue can have many, many messages and I would like to ensure that the consumer doesn't kill my database.
Is there a build-in way to perform throttling in RabbitMQ, either time-based(only X messages per minute/second/hour) or some other mechanism?
There is per-connection flow control, so if you have too much messages on server, publishers will be awaiting. RabbitMQ is very reliable system, i can say that you can no worry about it.
If you are talking about how to limit consumption, probably you have to take care about it by yourself. You may also look on channel.flow (deprecated as of RabbitMQ 3.3.0) and basic.qos methods or you can even temporary disconnect consumer(s) and reconnect them back when your services will be capable to take the load.
UPD
I can suggest that you consume messages with basic.consume and feed it to your web service. Based on how long does you web service process payload you may guess it's load and do some kind of sleep(N). While your consumer be sleeping it will not consume anything so no web service will be fed.
I'm wondering if "Per-Connection Flow Control" is related with the channel.flow().
Basically you can call channel.flow(false); to inform the broker to stop sending messages.
Calling channel.flow(true); makes the flow active again. Here's the javadoc.

How do I get a java application to subscribe to an NServiceBus publisher?

I've asked Google and searched through the NServiceBus website and forums, but I can't seem to find any prescriptive guidance on how I would write a Java application to subscribe to a publisher. Does anyone have any such link or experience?
This scenario is not well supported out of the box - you'll need to do some infrastructure munging yourself. In general, look at how the proxy is built, and add some gateway-style HTTP communication in the mix, or expose that with a standard .NET webservice.
You could manually send the subscribe message to the publisher over MSMQ, the publisher would then send any relevant messages to your java subscribers input queue. But you would need to receive those manually also.
I guess you're then committed to using MSMQ as your transport layer for your entire bus also.

Categories

Resources