Saturday, September 5, 2020

JMS in SOA

JMS Adapter

-> it is used to send or receive messages from JMS queue or topic.
-> Supports both inbound and outbound adapter service.

o   An inbound adapter service receive data from an external messaging system and
 transforms it into a xml message.
o     An outbound adapter service sends data to a target application by transforming an XML message into the native format of the given adapter.
->  Supports byte,text, and map message types.
->  Supports JMS headers and properties.
-> Support  jca.message .encoding  property

   Operation Types:

o   Consumer message [It polls for incoming messages from a JMS destination.]
o   Produce message [ It puts outgoing messages to a jms destination.]
o   Request/reply [It request for incoming messages from a jms destination and replies by putting messages to a jms destination  either synchrousenely or asynchrousenely.]
 o  Synchrounous Consume Message [It synchronously consume a message from a JMS destination without waiting.] 

JMS Java Messaging Service

JMS adapter is used to read/write data from/to JMS queue/topic. 

JMSServer

A JMS server acts as a management container for resources within JMSmodules. 

Some of its responsibilities include the maintenance of persistence and state of messages and subscribers. 

 A JMS server is required in order to create a JMS module.

JMS server is an environment-related configuration entity that acts as management container for JMS queue and topic resources defined within JMS modules that are targeted to specific that JMS server.

JMS Module(Optional)
Is a definition that contains various JMS Resources like queues, topics, etc.
JMS modules contain configuration resources, such as standalone queue and topic destinations, distributed destinations, and connection factories. In WebLogic Server these Configurations can be seen inside “<DOMAIN_HOME>/config/jms” Directory.

JMS Client
A JMS is a JMS applications that either produce messages to destinations or consume messages from destinations.

JNDI  
Java Naming And Directory interface,It is a Java API for a directory service that allows Java software clients to discover and look up data and objects via a name.

The Java Naming and Directory Interface™ (JNDI) is an application programming interface (API) that provides naming and directory functionality to applications written using the Java™ programming language. 
It is defined to be independent of any specific directory service implementation. 
Thus, a variety of directories -new, emerging, and already deployed can be accessed in a common way.
Persistent Store
-> A persistent store is a physical repository for storing subsystem data, such as persistent JMS messages.
-> It can be a JDBC-accessible database, disk-based file, or replicated memory storage. 
-> This page summarizes the persistent stores that have been created for this domain.
Ex(My Refrence):It will list all that store(file store,jdbc store,Replicated store ) which is created in JMS server.
-> It can be a User Defined Persistent Store or a Default Persistent store. It is used for storing the Data (Messages).
-> It is a physical location for a queue to store its messages.
There are two types of persistent stores
   1.Database persistent store
   2.File persistent store
-> The persistent store provides a built-in, high-performance storage solution for WebLogic Server subsystems and services that require persistence. 
-> For example, it can store persistent JMS messages or temporarily store messages sent using the Store-and-Forward feature. 
-> The persistent store supports persistence to a file-based store or to a JDBC-enabled database.
sub-Deployment(Optional)
-> A subdeployment is a mechanism by which JMS resources are grouped and targeted to a server instance, cluster, or SAF agent.
 -> A sub-deployment is a group of jms server and managed server.
-> JMS modules are targeted to one or more WLS instances or a cluster. Resources within a JMS module, such as queues and topics are also targeted to a JMS server or WLS server instances. 
-> A sub deployment is a grouping of targets. It is also known as advanced targeting.
Connection Factory  
-> A  connection factory is a Weblogic resource that enables JMS clients to create connections to JMS destinations
-> A connection factory is an object that a JMS client uses to create a connection with a JMS provider.
->We use connection factory in SOA suite tool to connect to server where JMS queue/topic created.
-> It’s a jms module or submodule 
-> It is a part of system module-0
-> Connection factory can be targeted to both jms server and the weblogic server.
But queue is only targated to jms server not t weblogic server.
Queue / Topic  the actual destination of the message, either a queue(point to point) or topic(publish-subscribe)
Queue: it is one to one jms module.
Topic: topic is one to many jms module.
Connection Pool
Create a pool of connections for the JMSAdapter application

What Is Difference Between Jms, Aq And Mq?
JMS is Java Message Queue which is open source
 AQ is advanced queue which is Oracle standard
MQ is message queue which is IBM standard

Why Jms, Aq And Mq Adapters Are Used?
JMS adapter is used to read/write data from/to JMS queue/topic.
AQ adapter is used to deal with AQ and 
same way MQ adapter is used to interact with MQ.

These Adapters Come Under Transnational Or Non-transnational Category?
These adapters come under transnational adapters category as these supports transactions.

What Is Difference Between Jms Queue And Topic?
Queue
-> JMS queue is used when we have one to one interaction, consumer put the message to JMS queue but only listener can pick the data from that queue as once that listener pick the data, data get deleted from the queue.
-> Defines a point-to-point destination type
-> which are used for asynchronous peer communications. 
-> A message delivered to a queue is distributed to only one consumer.
Topic
-> JMS topic is based on publish subscribe model, here multiple listeners/consumer can consume the same message.
-> JMS topic is used when we need to transfer same data to multiple places.
-> Defines a publish/subscribe destination type,
-> which are used for asynchronous peer communications.
-> A message delivered to a topic is distributed to all topic consumers.

What Is Message Selector Property?
When we read the data from JMS queue/topic based upon some condition then this property is used.
E.g. we use same queue to store different types of message so in one flow we need to pick only Sales Order information. so in sales order composite we use message selector property to pick only that record.

Can We Add Custom Header Properties To Jms Header While Sending Message To Jms Queue/topic?
Yes, we can do that.

Can We Read Custom Header Properties?
Yes, we can read custom header properties from JMS queue/topic by specifying the property name that we want to read.

Do We Always Need To Create Connection Factory?
No, you need to create only when you need to specify custom properties otherwise you can use default connection factories.

How We Can Do Retry Once Message Roll Back To Jms Queue?
We have “Deliver Failure” tab in JMS queue where we can set properties to do retry after certain intervals.

What Parameters We Need To Set In Delivery Failure Tab?
We need to set following parameters.

Redelivery Delay Override: Time interval between retries. It is in milliseconds.
Redelivery Limit: number of retries
Expiration Policy:
Redirect: redirect message to different queue.
Log: log the message.
Discard: discard message and it will be lost.
Error Destination: If you choose “Redirect” then chooses the queue to which you want to redirect message.

Which Property We Need To Use To Control Number Of Message Processed From Mq At One Time?
We need to use Inbound Thread Count property to control number of messages which MQ adapter pick from MQ.

Which Property We Need To Use With Singleton Property To Process The Message In Sequential Order For Aq?
We need to set activtionInstances=1 along with singleton property for AQ adapter in cluster environment to process message in sequential order.

Can We Set Polling Frequency For Aq And Mq Adapters?
No, we can’t set polling frequencies for AQ and MQ adapters as both the adapters are event driven.

Which Property We Have To Use To Process Jms, Aq Or Mq Messages On One Node In Cluster Environment?
We use singleton property in composite.xml file.

How we can delete message from JMS Queue?
Using WLST(weblogic scripting tool) commands to delete message from from a JMS message queue.


I have pushed one message in queue and before consuming my server went down, so what will you do, not to  lose data?
This can be achieved my using session acknowledgement.

For this first modify your producer code to use Session.AUTO_ACKNOWLEDGE. 
While creating Queue session, make AUTO_ACKNOWLEDGE as false. 
That means consumer has to acknowledge.

When the consumer sends acknowledgement of message, then the message will be deleted from the queue, 
otherwise it will remain in the queue.

On the consumer side you have to do the same thing, create a queue session with AUTO_ACKNOWLEDGE as false.

Distributed Queue
Whenever we are working on clustered environment , then we use Distributed queue.
"Defines a set of queues that are distributed on multiple JMS servers, but which are accessible as a single,  logical queue to JMS clients."

Distributed Topic
Whenever we are working on clustered environment , then we use Distributed Topic.
"Defines a set of topics that are distributed on multiple JMS servers, but which are accessible as a single,  logical topic to JMS clients."

JMS uses mostly Asynchrounous message:

watsApp: you send message need not be other person online at same time.
stock market
chatting
messenger
skype

1) JMS server is subset of managed server.
2) JMS server can be targeted strictly to one weblogic server instance only.(It can not be targeted on cluster or multiple server.)
3) One managed server can have multiple jms server but one jms server will be targeted to one single managed server.
4) To communicate with JMS server it have to go through submodules.
5) JMS submodule is subset of system module.
6) system module can be targeted to as many weblogic server (or managed server).
6) submodule can be target to many jms server.
7) some submodule is targeted to JMS server & some sobmodule is targeted to weblogic managed server. (we have to decide)
8) connection factory can be targeted to both jms erver and weblogic server.
9) queue is only targeted to jms server. 

EX:
"when sender send the hello, it will go to queue, store the message into connection factory, via a JMS server wich is targeted to manage server into the file store. "

Flow: message -> FileStore -> Queue -> JMSServer -> ManageServer

Note:

Any sender or receiver want to communicate with jms server then it has to go through submodule, It can’t communicate directly.
Jms server uses connection factory to communicate with file-store.
Managed server can directly write to a file store bcz we have created persistent store and targeted to managed server
Flow 
sender/receiver-> queue(any module) -> jmsserver1- managedServer(weblogic server) -> pick data from file store.
Once the data is picked by receiver from file store then msg will be deleted from filestore because it is one to one communication.


To check message in queue:

Go to Module -> queue -> Monitoring tab we can see number of message.

If we have multiple consumer and we are running loop then its depend whoever service will be free it will consume the message and delete message from queue. So to note only one service will consume data bcz queue is point to point.
 







No comments:

Post a Comment

SOA Overview Part-1

  Middleware It provides a mechanism for the process to interact with other processes running on multiple network machines. Advantages...