This page is under construction.
- Constructor arguments, refer to the JavaDoc of ThreadPoolExecutor
- corePoolSize: 10, maximumPoolSize: 20, keepAliveTime: 360, unit: TimeUnit.MILLISECONDS
- for a queue, receive is the standard JMS receive method.
- for topics, the receive() method is a blocking operation that create a 'temporary subscription'. The 'temporary subscription' wait for the first message and then unsubscribe and return the message. If a 'within' expiry time is provided, the 'temporary subscription' will be unsubscribed when the 'within' time is reached, and return null. This feature is typically used with message selector, and is useful for simulating a synchronous operation with the asynchronous JMS infrastructure. e.g. a client use a new thread to send a request with some delay, and in the main thread listen to the server response topic in synchronous manner.
def pool = new JMSPool() pool.send toQueue:'chatService',message:\[user:'groovy100',room:100\],delay:500 //it sends a message in another thread, the delay is avoid getting a result before the subscribed to the topic def result = pool.receive fromTopic:'signedOnBroadcast',messageSelector:"newUser = 'groovy100'" if (result) // you have successfully signed on else // retry? or tell user to sign in again.