Last active
August 29, 2016 08:59
-
-
Save cjjavellana/2b422e694e5acf253d22 to your computer and use it in GitHub Desktop.
Scala Akka Camel Weblogic JMS Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Properties | |
import org.apache.camel.component.jms.{ JmsComponent, JmsConfiguration } | |
import org.springframework.jms.support.destination.JndiDestinationResolver | |
import org.springframework.jndi.{ JndiObjectFactoryBean, JndiTemplate } | |
import akka.actor.{ ActorSystem, Props } | |
import akka.camel.CamelExtension | |
import javax.jms.ConnectionFactory | |
object ClientLauncher { | |
def main(args: Array[String]) { | |
val system = ActorSystem("system") | |
val camel = CamelExtension(system) | |
val camelContext = camel.context | |
camelContext.addComponent("jms", jmsComponent) | |
val actorRef = system.actorOf(Props[RequestMessageConsumer]) | |
val producer = system.actorOf(Props[ResponseMessageProducer]) | |
producer ! "Test" | |
} | |
def jndiTemplate: JndiTemplate = { | |
val jndiProperties = new Properties | |
jndiProperties.setProperty("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory") | |
jndiProperties.setProperty("java.naming.provider.url", "t3://localhost:7001") | |
val jndiTemplate = new JndiTemplate(jndiProperties) | |
jndiTemplate | |
} | |
def jndiDestinationResolver: JndiDestinationResolver = { | |
val jndiDestinationResolver = new JndiDestinationResolver | |
jndiDestinationResolver.setJndiTemplate(jndiTemplate) | |
jndiDestinationResolver | |
} | |
def connectionFactory: ConnectionFactory = { | |
val jndiObjectFactory = new JndiObjectFactoryBean | |
jndiObjectFactory.setJndiTemplate(jndiTemplate) | |
jndiObjectFactory.setJndiName("jms/connectionFactory") | |
jndiObjectFactory.afterPropertiesSet() | |
val jmsConnectionFactory = jndiObjectFactory.getObject.asInstanceOf[ConnectionFactory] | |
jmsConnectionFactory | |
} | |
def jmsConfiguration: JmsConfiguration = { | |
val jmsConfiguration = new JmsConfiguration | |
jmsConfiguration.setConnectionFactory(connectionFactory) | |
jmsConfiguration.setDestinationResolver(jndiDestinationResolver) | |
jmsConfiguration | |
} | |
def jmsComponent: JmsComponent = { | |
val jmsComponent = new JmsComponent(jmsConfiguration) | |
jmsComponent | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RequestMessageConsumer.scala
Message.scala
ResponseMessageProducer.scala