EchoServiceTestService.java
上传用户:xfwatch
上传日期:2020-12-14
资源大小:872k
文件大小:3k
源码类别:

中间件编程

开发平台:

Java

  1. /*
  2.  * JBoss, Home of Professional Open Source
  3.  * Copyright 2008, Red Hat, Inc., and others contributors as indicated
  4.  * by the @authors tag. All rights reserved.
  5.  * See the copyright.txt in the distribution for a
  6.  * full listing of individual contributors.
  7.  * This copyrighted material is made available to anyone wishing to use,
  8.  * modify, copy, or redistribute it subject to the terms and conditions
  9.  * of the GNU Lesser General Public License, v. 2.1.
  10.  * This program is distributed in the hope that it will be useful, but WITHOUT A
  11.  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12.  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  13.  * You should have received a copy of the GNU Lesser General Public License,
  14.  * v.2.1 along with this distribution; if not, write to the Free Software
  15.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  16.  * MA  02110-1301, USA.
  17.  */
  18. package org.jboss.blacktie.example.mdb;
  19. import javax.ejb.ActivationConfigProperty;
  20. import javax.ejb.MessageDriven;
  21. import org.jboss.blacktie.jatmibroker.core.conf.ConfigurationException;
  22. import org.jboss.blacktie.jatmibroker.xatmi.Buffer;
  23. import org.jboss.blacktie.jatmibroker.xatmi.Connection;
  24. import org.jboss.blacktie.jatmibroker.xatmi.ConnectionException;
  25. import org.jboss.blacktie.jatmibroker.xatmi.Response;
  26. import org.jboss.blacktie.jatmibroker.xatmi.TPSVCINFO;
  27. import org.jboss.blacktie.jatmibroker.xatmi.X_OCTET;
  28. import org.jboss.blacktie.jatmibroker.xatmi.mdb.MDBBlacktieService;
  29. import org.jboss.ejb3.annotation.Depends;
  30. @javax.ejb.TransactionAttribute(javax.ejb.TransactionAttributeType.NOT_SUPPORTED)
  31. @MessageDriven(activationConfig = {
  32. @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
  33. @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/EchoService") })
  34. @Depends("jboss.messaging.destination:service=Queue,name=EchoService")
  35. public class EchoServiceTestService extends MDBBlacktieService implements
  36. javax.jms.MessageListener {
  37. public EchoServiceTestService() throws ConnectionException,
  38. ConfigurationException {
  39. super("EchoService");
  40. }
  41. public Response tpservice(TPSVCINFO svcinfo) {
  42. X_OCTET rcvd = (X_OCTET) svcinfo.getBuffer();
  43. try {
  44. X_OCTET buffer = (X_OCTET) svcinfo.tpalloc("X_OCTET", null);
  45. buffer.setByteArray(rcvd.getByteArray());
  46. return new Response(Connection.TPSUCCESS, 0, buffer, rcvd
  47. .getByteArray().length, 0);
  48. } catch (ConnectionException e2) {
  49. e2.printStackTrace();
  50. return new Response(Connection.TPFAIL, 0, null, 0, 0);
  51. }
  52. }
  53. }