Search in sources :

Example 86 with TextMessage

use of javax.jms.TextMessage in project opennms by OpenNMS.

the class DaemonContextIT method canUseEmbeddedActiveMQBroker.

/**
 * Verifies that the embedded ActiveMQ broker bootstraps successfully
 * and is accessible using the provided connection factory.
 */
@Test
public void canUseEmbeddedActiveMQBroker() throws Throwable {
    QueueConnection connection = activeMQConnectionFactory.createQueueConnection();
    QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
    TextMessage message = session.createTextMessage();
    message.setText("ping");
    QueueSender sender = session.createSender(session.createQueue("pong"));
    sender.send(message);
}
Also used : QueueConnection(javax.jms.QueueConnection) QueueSender(javax.jms.QueueSender) QueueSession(javax.jms.QueueSession) TextMessage(javax.jms.TextMessage) Test(org.junit.Test)

Example 87 with TextMessage

use of javax.jms.TextMessage in project opennms by OpenNMS.

the class JmsNorthBounderTest method testForwardAlarms.

/**
 * This tests forwarding of 7 alarms, one for each OpenNMS severity to
 * verify the LOG_LEVEL agrees with the Severity based on our algorithm.
 *
 * @throws Exception the exception
 */
@Test
public void testForwardAlarms() throws Exception {
    String xml = generateConfigXml();
    Resource resource = new ByteArrayResource(xml.getBytes());
    JmsNorthbounderConfigDao dao = new JmsNorthbounderConfigDao();
    dao.setConfigResource(resource);
    dao.afterPropertiesSet();
    JmsNorthbounderConfig config = dao.getConfig();
    List<JmsDestination> destinations = config.getDestinations();
    List<JmsNorthbounder> nbis = new LinkedList<>();
    for (JmsDestination jmsDestination : destinations) {
        JmsNorthbounder nbi = new JmsNorthbounder(config, m_jmsNorthbounderConnectionFactory, jmsDestination);
        nbi.afterPropertiesSet();
        nbis.add(nbi);
    }
    int j = 7;
    List<NorthboundAlarm> alarms = new LinkedList<>();
    OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), NODE_LABEL);
    node.setForeignSource("TestGroup");
    node.setForeignId("1");
    node.setId(m_nodeDao.getNextNodeId());
    OnmsSnmpInterface snmpInterface = new OnmsSnmpInterface(node, 1);
    snmpInterface.setId(1);
    snmpInterface.setIfAlias("Connection to OpenNMS Wifi");
    snmpInterface.setIfDescr("en1");
    snmpInterface.setIfName("en1/0");
    snmpInterface.setPhysAddr("00:00:00:00:00:01");
    Set<OnmsIpInterface> ipInterfaces = new LinkedHashSet<OnmsIpInterface>(j);
    InetAddress address = InetAddress.getByName("10.0.1.1");
    OnmsIpInterface onmsIf = new OnmsIpInterface(address, node);
    onmsIf.setSnmpInterface(snmpInterface);
    onmsIf.setId(1);
    onmsIf.setIfIndex(1);
    onmsIf.setIpHostName(NODE_LABEL);
    onmsIf.setIsSnmpPrimary(PrimaryType.PRIMARY);
    ipInterfaces.add(onmsIf);
    node.setIpInterfaces(ipInterfaces);
    m_nodeDao.save(node);
    m_nodeDao.flush();
    // TX via NBIs
    for (JmsNorthbounder nbi : nbis) {
        for (int i = 1; i <= j; ++i) {
            OnmsAlarm onmsAlarm = new OnmsAlarm();
            onmsAlarm.setId(i);
            onmsAlarm.setUei("uei.opennms.org/test/jmsNorthBounder");
            onmsAlarm.setNode(node);
            onmsAlarm.setSeverityId(i);
            onmsAlarm.setIpAddr(InetAddress.getByName("127.0.0.1"));
            onmsAlarm.setCounter(i);
            onmsAlarm.setLogMsg("Node Down");
            onmsAlarm.setX733AlarmType(NorthboundAlarm.x733AlarmType.get(i).name());
            onmsAlarm.setX733ProbableCause(NorthboundAlarm.x733ProbableCause.get(i).getId());
            if (i < j) {
                // Do not add parameters to the last alarm for
                // testing NMS-6383
                OnmsEvent event = new OnmsEvent();
                event.setEventParameters(Lists.newArrayList(new OnmsEventParameter(event, "foreignSource", "fabric", "string"), new OnmsEventParameter(event, "foreignId", "space-0256012012000038", "string"), new OnmsEventParameter(event, "reason", "Aborting node scan : Agent timed out while scanning the system table", "string"), new OnmsEventParameter(event, ".1.3.6.1.4.1.2636.3.18.1.7.1.2.732", "207795895", "TimeTicks")));
                onmsAlarm.setLastEvent(event);
            }
            NorthboundAlarm a = new NorthboundAlarm(onmsAlarm);
            Assert.assertFalse(nbi.accepts(a));
            onmsAlarm.setUei("uei.opennms.org/nodes/nodeDown");
            a = new NorthboundAlarm(onmsAlarm);
            Assert.assertTrue(nbi.accepts(a));
            alarms.add(a);
        }
        nbi.forwardAlarms(alarms);
    }
    Thread.sleep(100);
    // Let's become a consumer and receive the messages!
    List<String> messages = new LinkedList<>();
    Message m = m_template.receive("OpenNMSAlarmQueue");
    while (m != null) {
        Assert.assertTrue(m instanceof TextMessage);
        messages.add(((TextMessage) m).getText());
        m = m_template.receive("OpenNMSAlarmQueue");
    }
    Assert.assertTrue("Log messages sent: 7, Log messages received: " + messages.size(), 7 == messages.size());
    for (String message : messages) {
        System.out.println(message);
    }
    int i = 0;
    for (String message : messages) {
        Assert.assertTrue("ALARM ID:" + (i + 1), message.contains("ALARM ID:" + (i + 1) + " "));
        Assert.assertTrue(message.contains("NODE:" + NODE_LABEL));
        i++;
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) JmsNorthbounderConfig(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfig) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm) OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsEventParameter(org.opennms.netmgt.model.OnmsEventParameter) JmsDestination(org.opennms.netmgt.alarmd.northbounder.jms.JmsDestination) OnmsNode(org.opennms.netmgt.model.OnmsNode) JmsNorthbounderConfigDao(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfigDao) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Resource(org.springframework.core.io.Resource) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) ByteArrayResource(org.springframework.core.io.ByteArrayResource) LinkedList(java.util.LinkedList) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) JmsNorthbounder(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounder) InetAddress(java.net.InetAddress) TextMessage(javax.jms.TextMessage) Test(org.junit.Test)

Example 88 with TextMessage

use of javax.jms.TextMessage in project opennms by OpenNMS.

the class JmsNorthBounderTest method testAlarmMappingNoParams.

@Test
public void testAlarmMappingNoParams() throws Exception {
    String xml = generateMappingConfigXml();
    Resource resource = new ByteArrayResource(xml.getBytes());
    JmsNorthbounderConfigDao dao = new JmsNorthbounderConfigDao();
    dao.setConfigResource(resource);
    dao.afterPropertiesSet();
    JmsNorthbounderConfig config = dao.getConfig();
    List<JmsDestination> destinations = config.getDestinations();
    List<JmsNorthbounder> nbis = new LinkedList<>();
    for (JmsDestination jmsDestination : destinations) {
        JmsNorthbounder nbi = new JmsNorthbounder(config, m_jmsNorthbounderConnectionFactory, jmsDestination);
        nbi.afterPropertiesSet();
        nbis.add(nbi);
    }
    List<NorthboundAlarm> alarms = new LinkedList<>();
    OnmsNode node = new OnmsNode(null, NODE_LABEL);
    node.setForeignSource("TestGroup");
    node.setForeignId("2");
    node.setId(m_nodeDao.getNextNodeId());
    OnmsIpInterface ip = new OnmsIpInterface("127.0.0.1", node);
    InetAddress ia = null;
    try {
        ia = InetAddress.getByName("127.0.0.1");
    } catch (UnknownHostException e) {
    }
    m_nodeDao.save(node);
    m_nodeDao.flush();
    // TX via NBIs
    for (JmsNorthbounder nbi : nbis) {
        OnmsEvent event = new OnmsEvent();
        event.setId(5);
        event.setEventUei("uei.uei.org/uei");
        event.setEventTime(new Date());
        event.setEventHost("eventhost");
        event.setEventSource("eventsource");
        event.setIpAddr(ia);
        event.setDistPoller(null);
        event.setEventSnmpHost("eventsnmphost");
        event.setServiceType(null);
        event.setEventSnmp("eventsnmp");
        event.setEventCreateTime(new Date());
        event.setEventDescr("eventdescr");
        event.setEventLogGroup("eventloggroup");
        event.setEventLogMsg("eventlogmsg");
        event.setEventSeverity(4);
        event.setEventPathOutage(null);
        event.setEventCorrelation(null);
        event.setEventSuppressedCount(0);
        event.setEventOperInstruct("operinstruct");
        event.setEventAutoAction(null);
        event.setEventOperAction(null);
        event.setEventOperActionMenuText(null);
        event.setEventNotification(null);
        event.setEventTTicket("tticketid");
        event.setEventTTicketState(1);
        event.setEventForward(null);
        event.setEventMouseOverText(null);
        event.setEventLog(null);
        event.setEventDisplay(null);
        event.setEventAckUser(null);
        event.setEventAckTime(null);
        event.setAlarm(null);
        event.setNode(node);
        event.setNotifications(null);
        event.setAssociatedServiceRegainedOutages(null);
        event.setAssociatedServiceLostOutages(null);
        OnmsAlarm alarm = new OnmsAlarm(9, event.getEventUei(), null, 1, 4, new Date(), event);
        alarm.setNode(node);
        alarm.setDescription(event.getEventDescr());
        alarm.setApplicationDN("applicationDN");
        alarm.setLogMsg(event.getEventLogMsg());
        alarm.setManagedObjectInstance("managedObjectInstance");
        alarm.setManagedObjectType("managedObjectType");
        alarm.setOssPrimaryKey("ossPrimaryKey");
        alarm.setQosAlarmState("qosAlarmState");
        alarm.setTTicketId("tticketId");
        alarm.setReductionKey("reductionKey");
        alarm.setClearKey("clearKey");
        alarm.setOperInstruct("operInstruct");
        alarm.setAlarmType(OnmsAlarm.PROBLEM_TYPE);
        alarm.setFirstEventTime(new Date(0));
        alarm.setIpAddr(ia);
        alarm.setX733AlarmType(NorthboundAlarm.x733AlarmType.get(1).name());
        alarm.setX733ProbableCause(NorthboundAlarm.x733ProbableCause.get(1).getId());
        NorthboundAlarm a = new NorthboundAlarm(alarm);
        alarms.add(a);
        nbi.forwardAlarms(alarms);
    }
    Thread.sleep(100);
    // Let's become a consumer and receive the message
    Message m = m_template.receive("MappingTestQueue");
    String escapedResponse = "ackUser:  appDn: applicationDN logMsg: eventlogmsg objectInstance: managedObjectInstance objectType: managedObjectType ossKey: ossPrimaryKey\n" + " ossState: qosAlarmState ticketId: tticketId alarmUei: uei.uei.org/uei alarmKey: reductionKey clearKey: clearKey description: eventdescr operInstruct: operInstruct ackTime: \n" + " alarmType: PROBLEM count: 1 alarmId: 9 ipAddr: 127.0.0.1 lastOccurrence:  nodeId: 1\n" + " nodeLabel: schlazor distPoller: 00000000-0000-0000-0000-000000000000 ifService:  severity: WARNING ticketState:  x733AlarmType: other\n" + " x733ProbableCause: other firstOccurrence: " + StringUtils.iso8601LocalOffsetString(new Date(0)) + " lastOccurrence  eventParmsXml: <eventParms/>";
    String response = ((TextMessage) m).getText();
    Assert.assertEquals("Contents of message\n'" + response + "'\n not equals\n'" + escapedResponse + "'.", response, escapedResponse);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) UnknownHostException(java.net.UnknownHostException) ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) JmsNorthbounderConfig(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfig) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) JmsNorthbounderConfigDao(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfigDao) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Resource(org.springframework.core.io.Resource) NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm) ByteArrayResource(org.springframework.core.io.ByteArrayResource) LinkedList(java.util.LinkedList) Date(java.util.Date) OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) JmsNorthbounder(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounder) JmsDestination(org.opennms.netmgt.alarmd.northbounder.jms.JmsDestination) InetAddress(java.net.InetAddress) TextMessage(javax.jms.TextMessage) Test(org.junit.Test)

Example 89 with TextMessage

use of javax.jms.TextMessage in project opennms by OpenNMS.

the class JmsNorthBounderTest method testAlarmMappings.

@Test
public void testAlarmMappings() throws Exception {
    String xml = generateMappingConfigXml();
    Resource resource = new ByteArrayResource(xml.getBytes());
    JmsNorthbounderConfigDao dao = new JmsNorthbounderConfigDao();
    dao.setConfigResource(resource);
    dao.afterPropertiesSet();
    JmsNorthbounderConfig config = dao.getConfig();
    List<JmsDestination> destinations = config.getDestinations();
    List<JmsNorthbounder> nbis = new LinkedList<>();
    for (JmsDestination jmsDestination : destinations) {
        JmsNorthbounder nbi = new JmsNorthbounder(config, m_jmsNorthbounderConnectionFactory, jmsDestination);
        nbi.afterPropertiesSet();
        nbis.add(nbi);
    }
    List<NorthboundAlarm> alarms = new LinkedList<>();
    OnmsNode node = new OnmsNode(null, NODE_LABEL);
    node.setForeignSource("TestGroup");
    node.setForeignId("2");
    node.setId(m_nodeDao.getNextNodeId());
    OnmsIpInterface ip = new OnmsIpInterface("127.0.0.1", node);
    InetAddress ia = null;
    try {
        ia = InetAddress.getByName("127.0.0.1");
    } catch (UnknownHostException e) {
    }
    m_nodeDao.save(node);
    m_nodeDao.flush();
    Date date1 = new Date(0);
    Date date2 = new Date();
    // TX via NBIs
    for (JmsNorthbounder nbi : nbis) {
        OnmsEvent event = new OnmsEvent();
        event.setId(5);
        event.setEventUei("uei.uei.org/uei");
        event.setEventTime(new Date());
        event.setEventHost("eventhost");
        event.setEventSource("eventsource");
        event.setIpAddr(ia);
        event.setDistPoller(null);
        event.setEventSnmpHost("eventsnmphost");
        event.setServiceType(null);
        event.setEventSnmp("eventsnmp");
        event.setEventParameters(Lists.newArrayList(new OnmsEventParameter(event, "syslogmessage", "Dec 22 2015 20:12:57.1 UTC :  %UC_CTI-3-CtiProviderOpenFailure: %[CTIconnectionId%61232238][ Login User Id%61pguser][Reason code.%61-1932787616][UNKNOWN_PARAMNAME:IPAddress%61172.17.12.73][UNKNOWN_PARAMNAME:IPv6Address%61][App ID%61Cisco CTIManager][Cluster ID%61SplkCluster][Node ID%61splkcucm6p]: CTI application failed to open provider%59 application startup failed", "string"), new OnmsEventParameter(event, "severity", "Error", "string"), new OnmsEventParameter(event, "timestamp", "Dec 22 14:13:21", "string"), new OnmsEventParameter(event, "process", "229250", "string"), new OnmsEventParameter(event, "service", "local7", "string")));
        event.setEventCreateTime(date2);
        event.setEventDescr("eventdescr");
        event.setEventLogGroup("eventloggroup");
        event.setEventLogMsg("eventlogmsg");
        event.setEventSeverity(4);
        event.setEventPathOutage(null);
        event.setEventCorrelation(null);
        event.setEventSuppressedCount(0);
        event.setEventOperInstruct("operinstruct");
        event.setEventAutoAction(null);
        event.setEventOperAction(null);
        event.setEventOperActionMenuText(null);
        event.setEventNotification(null);
        event.setEventTTicket("tticketid");
        event.setEventTTicketState(1);
        event.setEventForward(null);
        event.setEventMouseOverText(null);
        event.setEventLog(null);
        event.setEventDisplay(null);
        event.setEventAckUser(null);
        event.setEventAckTime(null);
        event.setAlarm(null);
        event.setNode(node);
        event.setNotifications(null);
        event.setAssociatedServiceRegainedOutages(null);
        event.setAssociatedServiceLostOutages(null);
        OnmsAlarm alarm = new OnmsAlarm(9, event.getEventUei(), null, 1, 4, new Date(), event);
        alarm.setNode(node);
        alarm.setDescription(event.getEventDescr());
        alarm.setApplicationDN("applicationDN");
        alarm.setLogMsg(event.getEventLogMsg());
        alarm.setManagedObjectInstance("managedObjectInstance");
        alarm.setManagedObjectType("managedObjectType");
        alarm.setOssPrimaryKey("ossPrimaryKey");
        alarm.setQosAlarmState("qosAlarmState");
        alarm.setTTicketId("tticketId");
        alarm.setReductionKey("reductionKey");
        alarm.setClearKey("clearKey");
        alarm.setOperInstruct("operInstruct");
        alarm.setAlarmType(OnmsAlarm.PROBLEM_TYPE);
        alarm.setFirstEventTime(date1);
        alarm.setIpAddr(ia);
        alarm.setLastEvent(event);
        alarm.setX733AlarmType(NorthboundAlarm.x733AlarmType.get(1).name());
        alarm.setX733ProbableCause(NorthboundAlarm.x733ProbableCause.get(1).getId());
        NorthboundAlarm a = new NorthboundAlarm(alarm);
        alarm.setCounter(2);
        NorthboundAlarm b = new NorthboundAlarm(alarm);
        alarms.add(a);
        alarms.add(b);
        nbi.forwardAlarms(alarms);
    }
    Thread.sleep(100);
    // Let's become a consumer and receive the message
    Message m = m_template.receive("MappingTestQueue");
    String escapedResponse = "ackUser:  appDn: applicationDN logMsg: eventlogmsg objectInstance: managedObjectInstance objectType: managedObjectType ossKey: ossPrimaryKey\n" + " ossState: qosAlarmState ticketId: tticketId alarmUei: uei.uei.org/uei alarmKey: reductionKey clearKey: clearKey description: eventdescr operInstruct: operInstruct ackTime: \n" + " alarmType: PROBLEM count: 1 alarmId: 9 ipAddr: 127.0.0.1 lastOccurrence: " + StringUtils.iso8601LocalOffsetString(date2) + " nodeId: 1\n" + " nodeLabel: schlazor distPoller: 00000000-0000-0000-0000-000000000000 ifService:  severity: WARNING ticketState:  x733AlarmType: other\n" + " x733ProbableCause: other firstOccurrence: " + StringUtils.iso8601LocalOffsetString(date1) + " lastOccurrence " + StringUtils.iso8601LocalOffsetString(date2) + " eventParmsXml: <eventParms>\n" + "    <parm name=\"syslogmessage\" value=\"Dec 22 2015 20:12:57.1 UTC :  %UC_CTI-3-CtiProviderOpenFailure: %[CTIconnectionId%61232238][ Login User Id%61pguser][Reason code.%61-1932787616][UNKNOWN_PARAMNAME:IPAddress%61172.17.12.73][UNKNOWN_PARAMNAME:IPv6Address%61][App ID%61Cisco CTIManager][Cluster ID%61SplkCluster][Node ID%61splkcucm6p]: CTI application failed to open provider%59 application startup failed\" type=\"string\"/>\n" + "    <parm name=\"severity\" value=\"Error\" type=\"string\"/>\n" + "    <parm name=\"timestamp\" value=\"Dec 22 14:13:21\" type=\"string\"/>\n" + "    <parm name=\"process\" value=\"229250\" type=\"string\"/>\n" + "    <parm name=\"service\" value=\"local7\" type=\"string\"/>\n" + "</eventParms>";
    String response = ((TextMessage) m).getText();
    Assert.assertEquals("Contents of message\n'" + response + "'\n not equals\n'" + escapedResponse + "'.", response, escapedResponse);
    // ensure only 1 message received since same reduction key
    m_template.setReceiveTimeout(JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT);
    m = m_template.receive("MappingTestQueue");
    Assert.assertNull(m);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) UnknownHostException(java.net.UnknownHostException) ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) JmsNorthbounderConfig(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfig) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) JmsNorthbounderConfigDao(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfigDao) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Resource(org.springframework.core.io.Resource) NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm) ByteArrayResource(org.springframework.core.io.ByteArrayResource) LinkedList(java.util.LinkedList) Date(java.util.Date) OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) JmsNorthbounder(org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounder) OnmsEventParameter(org.opennms.netmgt.model.OnmsEventParameter) JmsDestination(org.opennms.netmgt.alarmd.northbounder.jms.JmsDestination) InetAddress(java.net.InetAddress) TextMessage(javax.jms.TextMessage) Test(org.junit.Test)

Example 90 with TextMessage

use of javax.jms.TextMessage in project xmall by Exrick.

the class ItemESMessageListener method onMessage.

@Override
public void onMessage(Message message) {
    try {
        // 从消息中取商品id
        TextMessage textMessage = (TextMessage) message;
        log.info("得到消息:" + textMessage.getText());
        String[] text = textMessage.getText().split(",");
        Long itemId = new Long(text[1]);
        // 等待事务提交
        Thread.sleep(1000);
        // 更新索引
        Settings settings = Settings.builder().put("cluster.name", ES_CLUSTER_NAME).build();
        TransportClient client = new PreBuiltTransportClient(settings).addTransportAddress(new TransportAddress(InetAddress.getByName(ES_CONNECT_IP), 9300));
        if ("add".equals(text[0])) {
            // 根据商品id查询商品信息
            SearchItem searchItem = itemMapper.getItemById(itemId);
            String image = searchItem.getProductImageBig();
            if (image != null && !"".equals(image)) {
                String[] strings = image.split(",");
                image = strings[0];
            } else {
                image = "";
            }
            searchItem.setProductImageBig(image);
            IndexResponse indexResponse = client.prepareIndex(ITEM_INDEX, ITEM_TYPE, String.valueOf(searchItem.getProductId())).setSource(jsonBuilder().startObject().field("productId", searchItem.getProductId()).field("salePrice", searchItem.getSalePrice()).field("productName", searchItem.getProductName()).field("sub_title", searchItem.getSubTitle()).field("productImageBig", searchItem.getProductImageBig()).field("category_name", searchItem.getCategory_name()).endObject()).get();
        } else if ("delete".equals(text[0])) {
            DeleteResponse deleteResponse = client.prepareDelete(ITEM_INDEX, ITEM_TYPE, String.valueOf(itemId)).get();
        }
        log.info("处理消息成功");
        client.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : TransportClient(org.elasticsearch.client.transport.TransportClient) PreBuiltTransportClient(org.elasticsearch.transport.client.PreBuiltTransportClient) DeleteResponse(org.elasticsearch.action.delete.DeleteResponse) PreBuiltTransportClient(org.elasticsearch.transport.client.PreBuiltTransportClient) IndexResponse(org.elasticsearch.action.index.IndexResponse) TransportAddress(org.elasticsearch.common.transport.TransportAddress) TextMessage(javax.jms.TextMessage) Settings(org.elasticsearch.common.settings.Settings) SearchItem(cn.exrick.manager.dto.front.SearchItem)

Aggregations

TextMessage (javax.jms.TextMessage)231 Test (org.junit.Test)92 Session (javax.jms.Session)75 MessageProducer (javax.jms.MessageProducer)71 Message (javax.jms.Message)70 JMSException (javax.jms.JMSException)64 Connection (javax.jms.Connection)44 Destination (javax.jms.Destination)44 MessageConsumer (javax.jms.MessageConsumer)44 ObjectMessage (javax.jms.ObjectMessage)25 BytesMessage (javax.jms.BytesMessage)22 Queue (javax.jms.Queue)21 QueueSession (javax.jms.QueueSession)20 StubTextMessage (org.springframework.jms.StubTextMessage)18 ConnectionFactory (javax.jms.ConnectionFactory)13 QueueConnection (javax.jms.QueueConnection)13 CountDownLatch (java.util.concurrent.CountDownLatch)12 MapMessage (javax.jms.MapMessage)11 Topic (javax.jms.Topic)11 JMSContext (javax.jms.JMSContext)9