Created
March 12, 2011 07:30
-
-
Save avalade/867114 to your computer and use it in GitHub Desktop.
This file contains 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 bootstrap.liftweb.Application._ | |
import org.apache.activemq.ActiveMQConnectionFactory | |
import org.apache.activemq.command.ActiveMQTopic | |
import com.gs.tag.TagDatas.{State} | |
import com.gs.base_station.Payloads.TagPing | |
import javax.jms.{BytesMessage, MessageProducer, Session, Destination} | |
val conn = ctx.getBean("jmsFactory").asInstanceOf[ActiveMQConnectionFactory].createConnection | |
conn.start | |
val session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE) | |
val destination = { | |
val t = new ActiveMQTopic | |
t.setPhysicalName("tag_ping.8164") | |
t | |
} | |
val producer = session.createProducer(destination) | |
val state = State.GALLOPING | |
def send(session: Session, destination: Destination, state: State) = { | |
val producer = session.createProducer(destination) | |
val message = session.createBytesMessage | |
message.writeBytes(TagPing.newBuilder.setState(state).build.toByteArray) | |
producer.send(message) | |
producer.close | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment