Class CoreListener
- java.lang.Object
-
- org.wso2.carbon.inbound.endpoint.protocol.nats.CoreListener
-
- All Implemented Interfaces:
NatsMessageListener
public class CoreListener extends Object implements NatsMessageListener
Core listener class which uses core NATS connection to receive messages.
-
-
Constructor Summary
Constructors Constructor Description CoreListener(String subject, NatsInjectHandler injectHandler, Properties natsProperties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseConnection()Close the connection to NATS server and set connection to null.booleancreateConnection()Create the connection to the Core NATS server.io.nats.client.ConnectiongetNatsConnection()Create and return the Core NATS connection.voidinitializeConsumer(String sequenceName)Consume the message received and inject into the sequence.
-
-
-
Constructor Detail
-
CoreListener
public CoreListener(String subject, NatsInjectHandler injectHandler, Properties natsProperties)
-
-
Method Detail
-
createConnection
public boolean createConnection() throws IOException, InterruptedExceptionCreate the connection to the Core NATS server.- Specified by:
createConnectionin interfaceNatsMessageListener- Returns:
- boolean value whether connection is created.
- Throws:
IOExceptionInterruptedException
-
getNatsConnection
public io.nats.client.Connection getNatsConnection() throws IOException, InterruptedExceptionCreate and return the Core NATS connection.- Returns:
- the Core NATS connection.
- Throws:
IOExceptionInterruptedException
-
initializeConsumer
public void initializeConsumer(String sequenceName) throws IOException, InterruptedException
Consume the message received and inject into the sequence.- Specified by:
initializeConsumerin interfaceNatsMessageListener- Parameters:
sequenceName- the sequence to inject the message to.- Throws:
IOExceptionInterruptedException
-
closeConnection
public void closeConnection()
Close the connection to NATS server and set connection to null.- Specified by:
closeConnectionin interfaceNatsMessageListener
-
-