Spring Boot detect lost connection to GemFire - spring-data-gemfire

Does Spring Data GemFire provide any way to detect lost connection to GemFire Locator or Server from client-side application? I want to trigger an event to send an alert to inform user and then send request to other application to resend the information when connection is up.

Spring Data for VMware GemFire (SDG) does not in/directly (depending on your perspective) provide an API or means to detect when a client is disconnected from a cluster since GemFire/Geode already provides such mecahanisms.
See the ClientMembershipListener interface (Javadoc).
Use the ClientMembership (Javadoc) class to register an implementation instance of the interface.

Related

How to identify connections?

One of the Artemis web console views shows connections. I would like to identify connections. I would like to easily recognize which connection is from which application. I know that I can set Client ID but as I understand I have to use JMS API. Client ID can be set by calling org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory#setClientID method. ActiveMQConnectionFactory class is placed in org.apache.activemq:artemis-jms-client maven artifact.
Unfortunately I do not use JMS API and I do not want to use it. I use the Artemis core API (ServerLocator, ClientSessionFactory, ClientSession etc from the org.apache.activemq.artemis.api.core.client package). How to identity connections?
I found a way how to set Client ID. It can be set on org.apache.activemq.artemis.api.core.client.ClientSession instance:
public static String JMS_SESSION_CLIENT_ID_PROPERTY = "jms-client-id";
...
session.addMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY, "");
session.addMetaData(JMS_SESSION_CLIENT_ID_PROPERTY, "myClientID");

Can Window Service be used to have business Logic

There is requirement in project and the windows service needs to be used as subscriber of RabbitMQ (message broker).
Once the event has created, this listener windows service get the event and process the event, while processing, there are some important business logics needs to be incorporated and the data needs to be stored into SQL server DB.
From my perspective, windows service can be just a trigger of any business logic. Like once it subscribed to an event, if any event comes, read the event details and perform the business logic using any of the REST (HTTP based) service.
Please provide your suggestions, it would be more helpful. Thanks in advance.
You need to create a Windows application using c# or you can use NUGET rabbitmq client to consume message and save in dB.
https://www.nuget.org/packages/RabbitMQ.Client

Cloud readiness - looking for HTTP Session alternatives

We are planning to refactor our J2EE Monolith into Microservicesapplication. We are planning to build using Spring, Spring boot, Spring cloud and Pivotal cloud foundry as PaaS.
When i was validating whether my current application is cloud ready using The twelve-factor app , the important think i noticed is the usuage of 'HTTP Sessions' in our application. The link suggestes
Some web systems rely on “sticky sessions” – that is, caching user
session data in memory of the app’s process and expecting future
requests from the same visitor to be routed to the same process.
Sticky sessions are a violation of twelve-factor and should never be
used or relied upon. Session state data is a good candidate for a
datastore that offers time-expiration, such as Memcached or Redis.
I don't understand how can i use im-memory data store to track the user session? Could someone please explain? Should i use some unique key for users to retrieve information form in-memory data store?
As a good example, you can have a look on this explanation of Spring Session implementation
https://www.infoq.com/articles/Next-Generation-Session-Management-with-Spring-Session
It has a reference to Redis storage, which you can bind to your application from PCF services.

How to process the webservice xml message in mirth

How to process the webservice XML message in Mirth Connect 3.x?
If I understand your question correct, you are asking for how to configure Mirth to become a Web server. It's actually easy and hard at the same time.
The easy way - create a new channel and configure the Source connector as Web Service Listener. Deploy the channel and you have a web server waiting for SOAP messages to be sent to a configured IP port. But the structure of these SOAP messages is governed by Mirth WSDL at localhost:8081/services/Mirth?wsdl.
If you want the SOAP message structure to be different then you are going to deep dive into creating your own Java class and overriding default web service methods. There is no a single answer for that, it is a completely separate topic.
I hope you are asking how to consume XML webservice message in Mirth?..
If you are receiving specifically SOAP you need to set webservice listener as your source channel listener. (as said previous answer, you will have the URL)
Go to your transformer and type the following code:
logger.info(connectorMessage.getRawData());
Once you do this you can see the data you received inside Mirth on the logger area.

ejabberd in a microservice network

I'm willing to use ejabberd / mongooseIm in a microservice network. XMPP should be our chat protocol aside from a REST API network. I want to send messages incoming at the xmpp server downstream to worker services. Has anybody done this or could lead me into the right direction?
My first thoughts are using RabbitMQ for sending the new incoming messages to the workers.
There are basically two choices to giving your workers access to the messages routed by ejabberd / MongooseIM. I'll focus on MongooseIM, since I know it better (DISCLAIMER: I'm in the dev team).
The first is to scan the message archive in an async / polling fashion. The Message Archive Management describes XMPP level protocol for accessing it, but for your use case the important part is message persistence - so just making sure the relevant module (mod_mam) is enabled in server config and the messages will hit the database. The databases supported for MAM are PostgreSQL and Riak, though there was also some work on a Cassandra backend (YMMV). This doesn't require tinkering with the server / in Erlang for as long as there's a DB driver for your language of choice available. Since PR#657 it's possible to store the messages in raw XML or even some custom format if you're willing to write the serialization module.
The second option is to use the server mechanism of hooks and handlers (also available in ejabberd), which can trigger a server action on events like "user sent a message", "user logged in", "user logged out", ... This, however, requires a server side extension written in Erlang. In the simplest case the extension could forward any interesting event (with message content and metadata) via AMQP or just call some external HTTP/REST API - that way the real work is carried out by the workers giving you the freedom with regard to implementation language. This options also doesn't require to enable mod_mam or set up a database for message persistency (which you could still have with a persistent message queue...).
In general, the idea is perfectly feasible.
Generally, the most common XMPP extension use to build messaging systems for machines-to-machines, internet of things, microservices, etc is PubSub, as defined in XEP-0060.
This is a module you can enable in ejabberd. It is API based, so you can even customize the behaviour of that module to your application specific.
Pubsub basically allows to decouple senders and receivers and is especially designed for that use case.