package com.pgf.mqspring.service.impl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.JmsException; import org.springframework.jms.core.JmsTemplate; import org.springframework.stereotype.Service; import com.pgf.mqspring.service.CommonService; import com.pgf.mqspring.service.MqQlPoc01Test2ReceiveService; /** * QL.POC01.TESTから受信するサービスの実装クラス */ @Service public class MqQlPoc01Test2ReceiveServiceImpl implements MqQlPoc01Test2ReceiveService { private JmsTemplate jmsTemplate = null; private String que = ""; @Autowired CommonService commonService; public MqQlPoc01Test2ReceiveServiceImpl(JmsTemplate template) { this.jmsTemplate = template; } /** * {@inheritDoc} */ @Override public String receive(String id) { try { StringBuilder sb = new StringBuilder("JMSMessageID='"); sb.append(id); sb.append("'"); byte[] receiveByteMessage = (byte[]) jmsTemplate.receiveAndConvert(que); return commonService.decodeEbcdic(receiveByteMessage); } catch (JmsException ex) { ex.printStackTrace(); return "FAIL"; } } /** * {@inheritDoc} */ @Override public String getQue() { return que; } /** * {@inheritDoc} */ @Override public void setQue(String que) { this.que = que; } }