Hi Shinhung,
not sure I got you right, but here's how I've been working with akka
and JMS in the past:
1 - ad JMS connection)
If you use akka-camel, you'll have to rely on camel when it comes to
JMS connection management.
I.e. you register a new JMSComponent under a specific name (e.g.
"fooqueue") in akka-camel.
A JMSComponent needs a connectionfactory for interacting with a JMS
broker/queue.
The connectionfactory, however, requires all the connection
parameters, such as broker URL, user, password, queue-name, etc.
Having done that, all your actors can transparently use the camel
endpoint prefix "fooqueue:" to send send messages to that specific
queue.
The connection management (open/close) is transparent to your actor.
Slightly modified example from the akka-camel docs:
class MyActor extends Actor with Consumer {
def endpointUri = "fooqueue:tcp://localhost:6200?textline=true"
def receive = {
case msg: Message => { /* ... */}
case _ => { /* ... */}
}
}
2 - ad connection pooling)
As far as I know, camel/akka-camel does not natively support
connection pooling.
If you want to achieve that you'll have to register a pooling
ConnectionFactory.
If your JMS broker does not provide pooling capabilities, you can use
Spring's CachingConnectionFactory. - Don't worry you won't need an
application context and whatnot.
3 - ad no of actors vs no of connections)
1 actor can only process 1 message at a time.
Therefore, you won't make good use of a pool if you have only 1 actor.
However, if you use multiple akka-camel actors for parallel processing
and each of them uses the same queue (aka camel endpoint), they will
share the underlying connection.
If you use a pooled connection factory (see 1), they'll share the
connection pool.
I hope this helps!
cheers,
-Tom