Java Code Examples for org.apache.rocketmq.common.MixAll#file2String()
The following examples show how to use
org.apache.rocketmq.common.MixAll#file2String() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KVConfigManager.java From DDMQ with Apache License 2.0 | 6 votes |
public void load() { String content = null; try { content = MixAll.file2String(this.namesrvController.getNamesrvConfig().getKvConfigPath()); } catch (IOException e) { log.warn("Load KV config table exception", e); } if (content != null) { KVConfigSerializeWrapper kvConfigSerializeWrapper = KVConfigSerializeWrapper.fromJson(content, KVConfigSerializeWrapper.class); if (null != kvConfigSerializeWrapper) { this.configTable.putAll(kvConfigSerializeWrapper.getConfigTable()); log.info("load KV config table OK"); } } }
Example 2
Source File: LocalFileOffsetStore.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
private OffsetSerializeWrapper readLocalOffset() throws MQClientException { String content = MixAll.file2String(this.storePath); if (null == content || content.length() == 0) { return this.readLocalOffsetBak(); } else { OffsetSerializeWrapper offsetSerializeWrapper = null; try { offsetSerializeWrapper = OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class); } catch (Exception e) { log.warn("readLocalOffset Exception, and try to correct", e); return this.readLocalOffsetBak(); } return offsetSerializeWrapper; } }
Example 3
Source File: Consumer.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws InterruptedException, MQClientException, IOException { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroupNamecc4"); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); File classFile = new File(classLoader.getResource("MessageFilterImpl.java").getFile()); String filterCode = MixAll.file2String(classFile); consumer.subscribe("TopicTest", "org.apache.rocketmq.example.filter.MessageFilterImpl", filterCode); consumer.registerMessageListener(new MessageListenerConcurrently() { @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) { System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } }); consumer.start(); System.out.printf("Consumer Started.%n"); }
Example 4
Source File: DefaultMessageStore.java From DDMQ with Apache License 2.0 | 6 votes |
private long getInSyncOffsetSaved() { long offset = -1; String fileName = StorePathConfigHelper.getOffsetInSyncStorePath(this.messageStoreConfig.getStorePathRootDir()); try { File file = new File(fileName); if (file.exists()) { String offsetStr = MixAll.file2String(fileName); if (offsetStr != null) { offset = Long.valueOf(offsetStr); } file.delete(); } } catch (Exception ex) { log.error("get offset in sync failed", ex); } return offset; }
Example 5
Source File: Consumer.java From rocketmq-read with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws InterruptedException, MQClientException, IOException { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroupNamecc4"); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); File classFile = new File(classLoader.getResource("MessageFilterImpl.java").getFile()); String filterCode = MixAll.file2String(classFile); consumer.subscribe("TopicTest", "org.apache.rocketmq.example.filter.MessageFilterImpl", filterCode); consumer.registerMessageListener(new MessageListenerConcurrently() { @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) { System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } }); consumer.start(); System.out.printf("Consumer Started.%n"); }
Example 6
Source File: KVConfigManager.java From rocketmq-read with Apache License 2.0 | 6 votes |
/** * 启动时load */ public void load() { String content = null; try { content = MixAll.file2String(this.namesrvController.getNamesrvConfig().getKvConfigPath()); } catch (IOException e) { log.warn("Load KV config table exception", e); } if (content != null) { //从config.json中load出kvconfigSerializeWrapper对象,作为配置的项目 KVConfigSerializeWrapper kvConfigSerializeWrapper = KVConfigSerializeWrapper.fromJson(content, KVConfigSerializeWrapper.class); if (null != kvConfigSerializeWrapper) { this.configTable.putAll(kvConfigSerializeWrapper.getConfigTable()); log.info("load KV config table OK"); } } }
Example 7
Source File: KVConfigManager.java From rocketmq with Apache License 2.0 | 6 votes |
public void load() { String content = null; try { content = MixAll.file2String(this.namesrvController.getNamesrvConfig().getKvConfigPath()); } catch (IOException e) { log.warn("Load KV config table exception", e); } if (content != null) { KVConfigSerializeWrapper kvConfigSerializeWrapper = KVConfigSerializeWrapper.fromJson(content, KVConfigSerializeWrapper.class); if (null != kvConfigSerializeWrapper) { this.configTable.putAll(kvConfigSerializeWrapper.getConfigTable()); log.info("load KV config table OK"); } } }
Example 8
Source File: LocalFileOffsetStore.java From rocketmq with Apache License 2.0 | 6 votes |
private OffsetSerializeWrapper readLocalOffsetBak() throws MQClientException { String content = MixAll.file2String(this.storePath + ".bak"); if (content != null && content.length() > 0) { OffsetSerializeWrapper offsetSerializeWrapper = null; try { offsetSerializeWrapper = OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class); } catch (Exception e) { log.warn("readLocalOffset Exception", e); throw new MQClientException("readLocalOffset Exception, maybe fastjson version too low" // + FAQUrl.suggestTodo(FAQUrl.LOAD_JSON_EXCEPTION), // e); } return offsetSerializeWrapper; } return null; }
Example 9
Source File: KVConfigManager.java From DDMQ with Apache License 2.0 | 6 votes |
public void load() { String content = null; try { content = MixAll.file2String(this.namesrvController.getNamesrvConfig().getKvConfigPath()); } catch (IOException e) { log.warn("Load KV config table exception", e); } if (content != null) { KVConfigSerializeWrapper kvConfigSerializeWrapper = KVConfigSerializeWrapper.fromJson(content, KVConfigSerializeWrapper.class); if (null != kvConfigSerializeWrapper) { this.configTable.putAll(kvConfigSerializeWrapper.getConfigTable()); log.info("load KV config table OK"); } } }
Example 10
Source File: KVConfigManager.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
public void load() { String content = null; try { content = MixAll.file2String(this.namesrvController.getNamesrvConfig().getKvConfigPath()); } catch (IOException e) { log.warn("Load KV config table exception", e); } if (content != null) { KVConfigSerializeWrapper kvConfigSerializeWrapper = KVConfigSerializeWrapper.fromJson(content, KVConfigSerializeWrapper.class); if (null != kvConfigSerializeWrapper) { this.configTable.putAll(kvConfigSerializeWrapper.getConfigTable()); log.info("load KV config table OK"); } } }
Example 11
Source File: KVConfigManager.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
public void load() { String content = MixAll.file2String(this.namesrvController.getNamesrvConfig().getKvConfigPath()); if (content != null) { KVConfigSerializeWrapper kvConfigSerializeWrapper = KVConfigSerializeWrapper.fromJson(content, KVConfigSerializeWrapper.class); if (null != kvConfigSerializeWrapper) { this.configTable.putAll(kvConfigSerializeWrapper.getConfigTable()); log.info("load KV config table OK"); } } }
Example 12
Source File: SessionCredentials.java From rocketmq with Apache License 2.0 | 5 votes |
public SessionCredentials() { String keyContent = null; try { keyContent = MixAll.file2String(KEY_FILE); } catch (IOException ignore) { } if (keyContent != null) { Properties prop = MixAll.string2Properties(keyContent); if (prop != null) { this.updateContent(prop); } } }
Example 13
Source File: Consumer.java From rocketmq with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws InterruptedException, MQClientException, UnsupportedEncodingException { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroupNamecc4"); consumer.setNamesrvAddr("127.0.0.1:9876"); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); String filePath = URLDecoder.decode(classLoader.getResource("MessageFilterImpl.java").getFile(), "UTF-8"); File classFile = new File(filePath); String filterCode = MixAll.file2String(classFile); consumer.subscribe("TopicTest", "org.apache.rocketmq.example.filter.MessageFilterImpl", filterCode); consumer.registerMessageListener(new MessageListenerConcurrently() { @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) { System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } }); consumer.start(); System.out.printf("Consumer Started.%n"); }
Example 14
Source File: JDBCTransactionStore.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 4 votes |
private String createTableSql() { URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql"); String fileContent = MixAll.file2String(resource); return fileContent; }
Example 15
Source File: JDBCTransactionStore.java From DDMQ with Apache License 2.0 | 4 votes |
private String createTableSql() { URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql"); String fileContent = MixAll.file2String(resource); return fileContent; }
Example 16
Source File: JDBCTransactionStore.java From rocketmq with Apache License 2.0 | 4 votes |
private String createTableSql() { URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql"); String fileContent = MixAll.file2String(resource); return fileContent; }
Example 17
Source File: JDBCTransactionStore.java From rocketmq with Apache License 2.0 | 4 votes |
private String createTableSql() { URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql"); String fileContent = MixAll.file2String(resource); return fileContent; }
Example 18
Source File: JDBCTransactionStore.java From rocketmq-4.3.0 with Apache License 2.0 | 4 votes |
private String createTableSql() { URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql"); String fileContent = MixAll.file2String(resource); return fileContent; }
Example 19
Source File: JDBCTransactionStore.java From rocketmq_trans_message with Apache License 2.0 | 4 votes |
private String createTableSql() { URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql"); String fileContent = MixAll.file2String(resource); return String.format(fileContent, tableSuffix); }
Example 20
Source File: JDBCTransactionStore.java From DDMQ with Apache License 2.0 | 4 votes |
private String createTableSql() { URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql"); String fileContent = MixAll.file2String(resource); return fileContent; }