JMS心得
import org.springframework.jms.core.JmsTemplate;/** * the class use to receive the MQ message */public class JmsLogConsumer{ private JmsTemplate jmsTemplate; /** * @return Returns the jmsTemplate. */ public JmsTemplate getJmsTemplate() { return jmsTemplate; } /** * @param jmsTemplate The jmsTemplate to set. */ public void setJmsTemplate(JmsTemplate jmsTemplate) { this.jmsTemplate = jmsTemplate; } public Object receiveMessage() { return this.jmsTemplate.receiveAndConvert(); }}消费者rec
搜索接口总结
这次需求是采用2进制分别生成索引文件和数据文件,索引文件每次写21个字节,21个字节格式是固定的.数据文件里保存的是java对象,这里特别得注意,这个数据文件和索引文件最后都需要c程序修改的,最后我来解析:( 索引文件:long->bytes[],int->bytes[],偏移和长度必须正确.java中有read(bytes),每次读21个.数据文件采用的是RandomAccessFile,因为可以将文件指针移到开始,不必频繁打开数据流.移到开始只需要seek(0)就可以了.skipBytes(位移),然后read(bytes),最后oro正则解析.原来计算偏移用available后来发现不行,还是自己在写的时候就必
基础类型与字节数组相互转换函数
static long bytes2long(byte[] b) { //byte[] b=new byte[]{1,2,3,4}; long mask=0xff; long temp=0; long res=0; for(int i=0;i<8;i++){ res<<=8; temp=b[i]&mask; res|=temp; } return res; } static byte[] long2bytes(long num) { byte[] b=new byte[8]; for(int i=0;i<8;i++){ b[i]=(byte)(num>>>((7-i)*8))); } return b; } static int bytes2int(byte[] b){//byte[] b=new byte[]{1,2,3,4};int mask=0xff;int temp=0;int res=0;for(int i=0;i<4;i++){res<<=8;temp=b[i]&mask;res|=temp;}re