Search in sources :

Example 1 with RocketMQListenerFactory

use of com.qlangtech.async.message.client.consumer.RocketMQListenerFactory in project plugins by qlangtech.

the class TestPlugin method testReceiceRequestFromClient.

public void testReceiceRequestFromClient() throws Exception {
    com.alibaba.fastjson.JSONArray jsonArray = null;
    com.alibaba.fastjson.JSONObject jsonObject = null;
    com.alibaba.fastjson.JSONObject valJ = null;
    String impl = null;
    PropertyType attrDesc = null;
    Descriptor descriptor = null;
    JSONArray vals = null;
    String attr = null;
    String attrVal = null;
    TIS tis = TIS.get();
    // IncrComponent incrComponent = tis.loadIncrComponent(collection);
    // incrComponent.setMqListenerFactory();
    Describable describable = null;
    try (InputStream input = TestPlugin.class.getResourceAsStream("RocketMQListenerFactory.json")) {
        assertNotNull(input);
        jsonArray = JSONArray.parseArray(IOUtils.toString(input, TisUTF8.getName()));
        for (int i = 0; i < jsonArray.size(); i++) {
            // 创建一个item
            jsonObject = jsonArray.getJSONObject(i);
            describable = (Describable) parseDescribable(jsonObject).instance;
        }
    }
    assertNotNull(describable);
    RocketMQListenerFactory mqListenerFactory = (RocketMQListenerFactory) describable;
    assertEquals(MQ_TOPIC, mqListenerFactory.getMqTopic());
    assertEquals(NamesrvAddr, mqListenerFactory.getNamesrvAddr());
    assertEquals(consumeId, mqListenerFactory.consumeName);
    assertNotNull(mqListenerFactory.getDeserialize());
}
Also used : Describable(com.qlangtech.tis.extension.Describable) InputStream(java.io.InputStream) JSONArray(com.alibaba.fastjson.JSONArray) PropertyType(com.qlangtech.tis.extension.impl.PropertyType) JSONArray(com.alibaba.fastjson.JSONArray) Descriptor(com.qlangtech.tis.extension.Descriptor) JSONObject(com.alibaba.fastjson.JSONObject) RocketMQListenerFactory(com.qlangtech.async.message.client.consumer.RocketMQListenerFactory) TIS(com.qlangtech.tis.TIS)

Example 2 with RocketMQListenerFactory

use of com.qlangtech.async.message.client.consumer.RocketMQListenerFactory in project plugins by qlangtech.

the class TestIncrComponent method testLoad.

public void testLoad() {
    // IncrComponent incrComponent = TIS.get().loadIncrComponent(collection);
    IPluginStore<MQListenerFactory> pluginStore = TIS.getPluginStore(collection, MQListenerFactory.class);
    // assertNotNull(incrComponent);
    // incrComponent.getMqListenerFactory();
    List<MQListenerFactory> mqListenerFactoryList = pluginStore.getPlugins();
    assertEquals(1, mqListenerFactoryList.size());
    MQListenerFactory mqListenerFactory = mqListenerFactoryList.stream().findFirst().get();
    assertTrue(mqListenerFactory instanceof RocketMQListenerFactory);
    RocketMQListenerFactory rmFactory = (RocketMQListenerFactory) mqListenerFactory;
    assertEquals("c_otter_binlogorder_solr", rmFactory.getConsumeName());
    assertEquals("otter_binlogorder", rmFactory.getMqTopic());
    assertEquals("10.1.21.148:9876", rmFactory.getNamesrvAddr());
    assertTrue(rmFactory.getDeserialize() instanceof DefaultJSONFormatDeserialize);
// assertEquals(collection, incrComponent.getCollection());
}
Also used : DefaultJSONFormatDeserialize(com.qlangtech.async.message.client.to.impl.DefaultJSONFormatDeserialize) RocketMQListenerFactory(com.qlangtech.async.message.client.consumer.RocketMQListenerFactory) MQListenerFactory(com.qlangtech.tis.async.message.client.consumer.impl.MQListenerFactory) RocketMQListenerFactory(com.qlangtech.async.message.client.consumer.RocketMQListenerFactory)

Example 3 with RocketMQListenerFactory

use of com.qlangtech.async.message.client.consumer.RocketMQListenerFactory in project plugins by qlangtech.

the class TestPlugin method testSaveAndLoad.

public void testSaveAndLoad() throws IOException {
    // FileUtils.forceMkdir(tmpDir);
    try {
        // IncrComponent incrComponent = createIncrComponent();
        // TIS.get().saveComponent(collection, incrComponent);
        // incrComponent = TIS.get().loadIncrComponent(collection);
        IPluginStore<MQListenerFactory> pluginStore = TIS.getPluginStore(collection, MQListenerFactory.class);
        // incrComponent.getMqListenerFactory();
        List<MQListenerFactory> mqListenerFactory = pluginStore.getPlugins();
        assertEquals(1, mqListenerFactory.size());
        RocketMQListenerFactory rocketMQListenerFactory = (RocketMQListenerFactory) mqListenerFactory.get(0);
        // assertEquals(collection, incrComponent.getCollection());
        assertEquals(consumeId, rocketMQListenerFactory.consumeName);
        assertEquals(MQ_TOPIC, rocketMQListenerFactory.getMqTopic());
        assertEquals(NamesrvAddr, rocketMQListenerFactory.getNamesrvAddr());
        assertNotNull(rocketMQListenerFactory.getDeserialize());
        assertTrue(rocketMQListenerFactory.getDeserialize() instanceof DefaultJSONFormatDeserialize);
    } finally {
    // FileUtils.forceDelete(tmpDir);
    }
}
Also used : DefaultJSONFormatDeserialize(com.qlangtech.async.message.client.to.impl.DefaultJSONFormatDeserialize) RocketMQListenerFactory(com.qlangtech.async.message.client.consumer.RocketMQListenerFactory) MQListenerFactory(com.qlangtech.tis.async.message.client.consumer.impl.MQListenerFactory) RocketMQListenerFactory(com.qlangtech.async.message.client.consumer.RocketMQListenerFactory)

Aggregations

RocketMQListenerFactory (com.qlangtech.async.message.client.consumer.RocketMQListenerFactory)3 DefaultJSONFormatDeserialize (com.qlangtech.async.message.client.to.impl.DefaultJSONFormatDeserialize)2 MQListenerFactory (com.qlangtech.tis.async.message.client.consumer.impl.MQListenerFactory)2 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 TIS (com.qlangtech.tis.TIS)1 Describable (com.qlangtech.tis.extension.Describable)1 Descriptor (com.qlangtech.tis.extension.Descriptor)1 PropertyType (com.qlangtech.tis.extension.impl.PropertyType)1 InputStream (java.io.InputStream)1