Class XTablesMessageQueue
- All Implemented Interfaces:
Runnable
This class initializes and manages the components required for handling message queues using JeroMQ. It leverages a blocking queue for message buffering and operates in a multithreaded environment.
Author: Kobe Lei Version: 1.0 Package: org.kobe.xbot.JServer
This is part of the XTABLES project and facilitates efficient message processing and publication in real-time applications.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class org.kobe.xbot.JServer.BaseHandler
logger, socket
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionXTablesMessageQueue
(org.zeromq.ZMQ.Socket socket, XTablesServer instance) Constructor for initializing the XTablesMessageQueue. -
Method Summary
Methods inherited from class org.kobe.xbot.JServer.BaseHandler
cleanUp, handleException, interrupt
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
XTablesMessageQueue
Constructor for initializing the XTablesMessageQueue.This constructor sets up the handler thread with a specified name, daemon mode, and the provided JeroMQ socket. It also initializes a blocking queue to buffer messages for asynchronous processing.
- Parameters:
socket
- The ZeroMQ socket to receive and send messages
-
-
Method Details
-
send
public void send(byte[] message) Adds a message to the queue for asynchronous processing.This method places the provided message into the blocking queue. If the queue is full, the message will be rejected silently.
- Parameters:
message
- The byte array message to enqueue for processing
-
run
public void run()The main processing loop for handling incoming messages.This method continuously retrieves messages from the blocking queue and sends them through the JeroMQ socket. The loop runs until the thread is interrupted. Any exception encountered is passed to the handler's exception processor.
-