You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by e271828 <16...@qq.com> on 2017/05/24 01:52:19 UTC

BlobMessage in ActiveMQ-CPP by now 2017

I'm searching the documentation of ActiveMQBlobMessage usage in C++ through
ActiveMQ-CPP. I could find http://activemq.apache.org/blob-messages.html and
it talks about Java usage and expecting the similar one for C++. Can you
please let me know from where we can get it? 

==========================
I  see  this  question  in  this  web  site ,but  it  is  posted  at 2008.
I  donot  known  wheather  this  problem is  solved  by  now   2017.
I am a chinese.My  English is not  good.Reading  English  is very hardly.

Can you help me?
Thanks.



--
View this message in context: http://activemq.2283324.n4.nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by e271828 <16...@qq.com>.
I add a new message named blobmessageLi which like textmessage but not like
original blobmessage,
I add blobmessageli.h and cpp file whick like textmessage.h and cpp in cms
directory.
I add ActiveMQBlobMessageli.h and cpp file,ActiveMQBlobMessageMarshaller.h
and cpp.
And modify relational code,ID_ACTIVEMQBLOBMESSAGELI =
29;ID_ACTIVEMQBLOBMESSAGE = 41;
Now I can send my blobmessageLi from C++ with setStringProperty which java
can receive my blobmessage 

with getStringProperty.
But send the setRemoteBlobUrl from C++ which can not be received by java
either.
It seems that this approach is harder to implement setRemoteBlobUrl and
getRemoteBlobUrl.



--
View this message in context: http://activemq.2283324.n4.nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726631.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by e271828 <16...@qq.com>.
I can do as follow,and change the java to delphi and C++,but my manager do
not agree do that.
=============================================
package com.blob.activemq;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.Socket;
import java.net.URL;
import java.net.UnknownHostException;

/*
 * 客户端
 */
public class SoBlob {
	public static String keywww;
    public static void main(String[] args) {
    	
    	String oldid="ID:WWW-5DAA99645BA-3700-1494653738046-";
    	String newid="ID_WWW-5DAA99645BA-4047-1494657860484-";
    	URL url = null;//createMessageURL(message);
    	  try {
		
//http://192.168.2.227:8161/fileserver/ID:WWW-5DAA99645BA-4345-1494661885140-1:1:1:1:1
		//url=new URL("http://192.168.2.227:8161/fileserver/"+newid+"1:1:1:1:1");
		url=new URL("http://localhost:8161/fileserver/"+newid+"1:1:1:1:1");
    	  } catch (MalformedURLException e2) {
			// TODO Auto-generated catch block
			e2.printStackTrace();
		}
    	File file = new File("c:\\www.jpg");
    	FileInputStream fis = null;
    	HttpURLConnection connection = null;
		try {
			fis = new FileInputStream(file);
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}		
    	//InputStream fis=new inputstream(file);
         try {
			connection = (HttpURLConnection)url.openConnection();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
			try {
				connection.setRequestMethod("PUT");
			} catch (ProtocolException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

        connection.setDoOutput(true);


        // use chunked mode or otherwise URLConnection loads everything into
        // memory
        // (chunked mode not supported before JRE 1.5)
       
//connection.setChunkedStreamingMode(transferPolicy.getBufferSize());
        connection.setChunkedStreamingMode((int) file.length());
        try(OutputStream oss = connection.getOutputStream()) {
            byte[] buf =new byte[(int) file.length()];//new
byte[transferPolicy.getBufferSize()];
            for (int c = fis.read(buf); c != -1; c = fis.read(buf)) {
                oss.write(buf, 0, c);
                oss.flush();
            }
        } catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	///////////////////////////////////////////////////////////
        try {
            //1.创建客户端Socket,指定服务器地址和端口
            //Socket socket=new Socket("192.168.2.227", 61616);
            Socket socket=new Socket("localhost", 61616);
            //2.获取输出流,向服务器端发送信息
            OutputStream os=socket.getOutputStream();//字节输出流
            //PrintWriter pw=new PrintWriter(os);//将输出流包装为打印流
            //pw.write("用户名:whf;密码:789");
            //pw.flush();

        	//os.write(buffer99, 0, buffer99.length);
        	//os.flush();

            So.keywww=newid;
            int[]  BBB={398,101,139,59,85,211,21,21,21,21,11};
            ///*
            String
B0="0000018A014163746976654D510000000C01000001780000000D0009436163686553697A650500000400000C4D61784672616D6553697A65067FFFFFFFFFFFFFFF000C4361636865456E61626C656401010004486F737409000D3139322E3136382E322E323237000C50726F76696465724E616D650900084163746976654D51001253697A6550726566697844697361626C6564010000204D6178496E61637469766974794475726174696F6E496E6974616C44656C617906000000000000271000145469676874456E636F64696E67456E61626C656401010011537461636B5472616365456E61626C65640101000F50726F766964657256657273696F6E0000115463704E6F44656C6179456E61626C65640101000F506C6174666F726D44657461696C730900454A564D3A20312E372E305F30312C2032312E312D6230322C204F7261636C6520436F72706F726174696F6E2C204F533A2057696E646F77732058502C20352E312C2078383600154D6178496E61637469766974794475726174696F6E06000000000000753000";
        	String
B1="0000006103027F1800000001000078002949443A5757572D35444141393936343542412D333730302D313439343635333733383034362D313A31002949443A5757572D35444141393936343542412D333730302D313439343635333733383034362D303A3132                                                                                                                                                                                                                                                                                                                                                                                       
";
        	String
B2="0000008705047F7D04000000000200017A002949443A5757572D35444141393936343542412D333730302D313439343635333733383034362D313A31FFFFFFFFFFFFFFFF000100026500374163746976654D512E41647669736F72792E54656D7051756575652C4163746976654D512E41647669736F72792E54656D70546F706963000003E8000000000078                                                                                                                                                                                                                                                                                                                                                                                       
";
        	String
B3="0000003704015E00000003000379002949443A5757572D35444141393936343542412D333730302D313439343635333733383034362D313A31000131                                                                                                                                                                                                                                                                                                                                                                                       
";
        	String
B4="0000005106025F1F0000000400047B002949443A5757572D35444141393936343542412D333730302D313439343635333733383034362D313A3100010001000564000E46696C652E5472616E73706F72740000000064                                                                                                                                                                                                                                                                                                                                                                                       
";
        	String
B5="000000CF1D0648043001001F0000000500040005000600066E00040001000600000000040000015C004E1FF80000002D00000002000946494C452E53495A450600000000000122F8000946494C452E4E414D450900077777772E6A70670006000000000054687474703A2F2F3139322E3136382E322E3232373A383136312F66696C657365727665722F49443A5757572D35444141393936343542412D333730302D313439343635333733383034362D313A313A313A313A3100186170706C69636174696F6E2F6F637465742D73747265616D62";
        	String B6="000000110C010C000000060004FFFFFFFFFFFFFFFE06";
        	String B7="000000110C010C000000070003FFFFFFFFFFFFFFFE06";
        	String B8="000000110C010C000000080001FFFFFFFFFFFFFFFE06";
        	String B9="000000110C010D000000090000FFFFFFFFFFFFFFFF06";
        	String B10="000000070B01000000000A00";
           // */
        	//So.keywww="ID:WWW-5DAA99645BA-2748-1494638863984-";
        	 So.keywww=bytes2HexString(So.keywww.getBytes());       	
        	System.out.println("B0");
        	printchar(hexStringToBytes(B0));
        	byte[] buffer=hexStringToBytes(B0);
        	os.write(buffer, 0, BBB[0]);
        	os.flush();
        	/*
还有参数的替换问题。
文件名可替换,但文件名长度不能变。是不是队列名一样长度不能变?
且可能只能是英文名,不可中文名?
文件大小的数值或可以不理,如果理,是不是数值的长度也不能变化?
这些小事想起来也会烦人的。
        	*/
        	System.out.println("B1");
        	
        	printchar(hexStringToBytes(B1));
        	byte[] wwwbb1=oldid.getBytes();
        	String wwwb1=bytes2HexString(wwwbb1);
        	B1=B1.replaceAll(wwwb1, So.keywww);
        	
        	byte[] buffer1=hexStringToBytes(B1);
        	printchar((buffer1));
        	os.write(buffer1, 0, BBB[1]);
        	os.flush();
        	
        	System.out.println("B2");
        	printchar(hexStringToBytes(B2));

        	B2=B2.replaceAll(wwwb1, So.keywww);
        	byte[] buffer2=hexStringToBytes(B2);
        	printchar((buffer2));
        	os.write(buffer2, 0, BBB[2]);
        	os.flush();
        	try {
				Thread.sleep(1);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        	
        	System.out.println("B3");
        	printchar(hexStringToBytes(B3));

        	B3=B3.replaceAll(wwwb1, So.keywww);
        	byte[] buffer3=hexStringToBytes(B3);
        	printchar((buffer3));
        	os.write(buffer3, 0, BBB[3]);
        	os.flush();
        	
        	System.out.println("B4");
        	printchar(hexStringToBytes(B4));

       	B4=B4.replaceAll(wwwb1, So.keywww);
        	byte[] buffer4=hexStringToBytes(B4);
        	printchar((buffer4));
        	os.write(buffer4, 0, BBB[4]);
        	os.flush();
        	
        	
        	System.out.println("B5");
        	printchar(hexStringToBytes(B5));
        	B5=B5.replaceAll(wwwb1, So.keywww);
        	B5=B5.replaceAll(bytes2HexString("www.jpg".getBytes()),
bytes2HexString("qqq.jpg".getBytes()));
        	printchar(hexStringToBytes(B5));
        	byte[] buffer5=hexStringToBytes(B5);
        	os.write(buffer5, 0, BBB[5]);
        	os.flush();
        	System.out.println("B6");
        	printchar(hexStringToBytes(B6));
        	byte[] buffer6=hexStringToBytes(B6);
        	os.write(buffer6, 0, BBB[6]);
        	os.flush();
        	
        	System.out.println("B7");
        	printchar(hexStringToBytes(B7));
        	byte[] buffer7=hexStringToBytes(B7);
        	os.write(buffer7, 0, BBB[7]);
        	os.flush();
        	System.out.println("B8");
        	printchar(hexStringToBytes(B8));
        	byte[] buffer8=hexStringToBytes(B8);
        	os.write(buffer8, 0, BBB[8]);
        	os.flush();
        	System.out.println("B9");
        	printchar(hexStringToBytes(B9));
        	byte[] buffer9=hexStringToBytes(B9);
        	os.write(buffer9, 0, BBB[9]);
        	os.flush();
        	System.out.println("B10");
        	printchar(hexStringToBytes(B10));
        	byte[] buffer10=hexStringToBytes(B10);
        	os.write(buffer10, 0, BBB[10]);
        	os.flush();
        	
        	 
            socket.shutdownOutput();//关闭输出流
            
            //3.获取输入流,并读取服务器端的响应信息
            InputStream is=socket.getInputStream();
            BufferedReader br=new BufferedReader(new InputStreamReader(is));
            String info=null;
            while((info=br.readLine())!=null){
                System.out.println("我是客户端,服务器说:"+info);
            }
            //4.关闭资源
            br.close();
            is.close();
            //pw.close();
            os.close();
            socket.close();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static byte[] hexStringToBytes(String hexString) {
        if (hexString == null || hexString.equals("")) {
            return null;
        }
        hexString = hexString.toUpperCase();
        int length = hexString.length() / 2;
        char[] hexChars = hexString.toCharArray();
        byte[] d = new byte[length];
        for (int i = 0; i < length; i++) {
            int pos = i * 2;
            d[i] = (byte) (charToByte(hexChars[pos]) << 4 |
charToByte(hexChars[pos + 1]));
            
        }
        return d;
    }
    private static byte charToByte(char c) {
        return (byte) "0123456789ABCDEF".indexOf(c);
    }
    public static byte[] hexStringToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        try {
            for (int i = 0; i < len; i += 2) {
                data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) <<
4)
                        + Character.digit(s.charAt(i+1), 16));
            }
        } catch (Exception e) {
            //Log.d("", "Argument(s) for hexStringToByteArray(String s)"+
"was not a hex string");
        }
        return data;
    }
    public static String bytes2HexString(byte[] b) {  
    	  String ret = "";  
    	  for (int i = 0; i < b.length; i++) {  
    	   String hex = Integer.toHexString(b[ i ] & 0xFF);  
    	   if (hex.length() == 1) {  
    	    hex = '0' + hex;  
    	   }  
    	   ret += hex.toUpperCase();  
    	  }  
    	  return ret;  
    	}
    public static void printchar(byte[] www){
    	String sss="";
    	for (int ii=0;ii<=www.length-1;ii++){
    	sss=sss+(char)www[ii];}
    	System.out.println(sss);
        }
}



--
View this message in context: http://activemq.2283324.n4.nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726458.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by Tim Bain <tb...@alumni.duke.edu>.
One advantage of sending the URL via a blob message instead of just custom
encoding it into a text message is that you don't have to write the custom
encoding and decoding code.

Java also has an ActiveMQBlobMessage class (
http://activemq.apache.org/maven/5.13.3/apidocs/org/apache/activemq/command/ActiveMQBlobMessage.html),
so you would be able to send one in Java and receive it in C++ or vice
versa. But if you used features in one language that were not implemented
in the other, then obviously you may not get full compatibility.

Tim

On May 24, 2017 8:04 PM, "e271828" <16...@qq.com> wrote:

Thanks,now I know that C++ client can only send and receive the URL,can not
directly upload or download the blob file.
If so that ,why I use blobmessage in C++ ,I can use textmessage instead of
blobmessage,send and receive URL through by textmessae?
my  c++ code as follow:
commands::ActiveMQBlobMessage* message = new
commands::ActiveMQBlobMessage();
        message->setStringProperty( "FILE.NAME", "www.jpg" );
        message->setRemoteBlobUrl("c:\\www.jpg")
        producer->send( message );
but my java code can not receive the  blobmessage StringProperty
"FILE.NAME".
public void onMessage(Message message) {
                if (message instanceof BlobMessage) {
                    BlobMessage blobMessage = (BlobMessage) message;
                    String fileName =
blobMessage.getStringProperty("FILE.NAME");}
If it is textmessage,my java code can read the StringProperty  "FILE.NAME".
Does c++ send blobmessage which can only receive by C++ and can not receive
by java?



--
View this message in context: http://activemq.2283324.n4.
nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726533.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by e271828 <16...@qq.com>.
Thanks,now I know that C++ client can only send and receive the URL,can not
directly upload or download the blob file.
If so that ,why I use blobmessage in C++ ,I can use textmessage instead of
blobmessage,send and receive URL through by textmessae?
my  c++ code as follow:
commands::ActiveMQBlobMessage* message = new
commands::ActiveMQBlobMessage();
 	message->setStringProperty( "FILE.NAME", "www.jpg" );
        message->setRemoteBlobUrl("c:\\www.jpg")
        producer->send( message );  
but my java code can not receive the  blobmessage StringProperty 
"FILE.NAME".
public void onMessage(Message message) {  
                if (message instanceof BlobMessage) {  
                    BlobMessage blobMessage = (BlobMessage) message;   
                    String fileName =
blobMessage.getStringProperty("FILE.NAME");}
If it is textmessage,my java code can read the StringProperty  "FILE.NAME".
Does c++ send blobmessage which can only receive by C++ and can not receive
by java?



--
View this message in context: http://activemq.2283324.n4.nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726533.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by e271828 <16...@qq.com>.
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP;

type
  TForm1 = class(TForm)
    Button1: TButton;
    IdHTTP1: TIdHTTP;
    IdTCPClient1: TIdTCPClient;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function sendbytes(b: string; L: integer): longInt;
  end;

var
  Form1: TForm1;

implementation

function HexToInt(Str1: string): longInt;
var i: integer;
begin
  Result := 0;
  for i := 1 to length(Str1) do
  begin
    if (Str1[i] >= '0') and (Str1[i] <= '9') then
      Result := Result * 16 + StrToInt(Str1[i])
    else
    begin
      if (Str1[i] >= 'A') and (Str1[i] <= 'F') then
        result := Result * 16 + ord(Str1[i]) - 55
      else
      begin
        result := 0;
        exit;
      end;
    end;
  end;
end;

function FileToString(mFileName: TFileName): string;
var
  I: Integer;
  mStream: tfilestream;
  bb: byte;
begin
  mStream := tfilestream.Create(mFileName, fmOpenRead);
  Result := '';
  if not Assigned(mStream) then Exit;
//SetLength(Result,   mStream.Size);
  for I := 0 to Pred(mStream.Size) do try
    mStream.Position := I;

    mStream.Read(bb, 1);
    Result := Result + inttohex(bb, 2);

  except
    Result := '';
  end;
  mStream.Destroy;
end; {   StreamToString   }

function StringToFile(mString: string; mFileName: TFileName): Boolean;
  {   返回字符串保存到文件是否成功   }
var
  I, j: Integer;
  mStream: tfilestream;
  bb: byte;
  ss: string;
begin
  Result := True;
  mStream := tfilestream.Create(mFileName, fmCreate);
  try
    mStream.Size := 0;
    mStream.Position := 0;
    j := 0;
    for I := 1 to Length(mString) do
    begin
      ss := ss + mString[I];
      j := j + 1;
      if j = 2 then
      begin
        j := j div 2;
        bb := hextoint(ss);
        mStream.Write(bb, j);
        j := 0;
        ss := ''; //加此则很快了。
      end;
    end;
    if j > 0 then
    begin
      j := j div 2;
      bb := hextoint(ss);
      mStream.Write(bb, j);

    end;
  except
    Result := False;

  end;
  mStream.Destroy;
end; {   StringToStream   }
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  UpLoadFile: TFileStream;
  oldid, newid, keywww: string;
  B0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10: string;
  i, j: integer;
  ss, b: string;
begin
  oldid := 'ID:WWW-5DAA99645BA-3700-1494653738046-';
  newid := 'ID_WWW-5DAA99645BA-4047-1494657860484-';
  UpLoadFile := TFileStream.Create('c:\www.jpg', fmOpenRead);
 
//UpLoadFile:=TFileStream.Create('E:\软件大全\Dreamweaver_CS6.zip',fmOpenRead);
 // DownLoadFile:=TFileStream.Create(LocalPath+'\lm.gif',fmCreate);
  try
  
//idHttp1.Put('http://192.168.2.227:8161/fileserver/'+newid+'1:1:1:1:1',UpLoadFile);
    idHttp1.Put('http://localhost:8161/fileserver/' + oldid + '1:1:1:1:1',
UpLoadFile);
  except
    showMessage('上传失败');
    exit;
  end;
  showMessage('上传成功');
  ///////////////////
  keywww := newid;
  //下面尚未替换子串的。
  B0 := '0000018A014163746976654D510000000C01000001780000000' +
'D0009436163686553697A650500000400000C4D61784672616D6553697A65067FFFFFFFFFFFFFFF000C4361636865456E61626C656401010004486F737409000D3139322E3136382E322E323237000C50726F76696465724E616D650900084163746976654D51001253697A6550726566697844697361626C656401000020'
+
'4D6178496E61637469766974794475726174696F6E496E6974616C44656C617906000000000000271000145469676874456E636F64696E67456E61'
+
'626C656401010011537461636B5472616365456E61626C65640101000F50726F766964657256657273696F6E0000115463704E6F44656C6179456E61626C65640101000F506C6174666F726D44657461696C730900454A564D3A20312E372E305F30312'
+
'C2032312E312D6230322C204F7261636C6520436F72706F726174696F6E2C204F533A2057696E646F77732058502C20352E312C2078383600154D6178496E61637469766974794475726174696F6E06000000000000753000';
  B1 := '0000006103027F1800000001000078002949443A5757572D354441' +
'41393936343542412D333730302D313439343635333733383034362D313A31002949443A5757572D35444141393936343542412D333730302D313439343635333733383034362D303A3132'
+ '                                                                                                                                                                                              
' + '                                                                                                                                                                                        
';
  B2 := '0000008705047F7D04000000000200017A002949443A5757572D354' +
'44141393936343542412D333730302D313439343635333733383034362D313A31FFFFFFFFFFFFFFFF000100026500374163746976654D512E41647669736F72792E54656D7051756575652C4163746976654D512E41647669736F72792E54656D70546F706963000003E8000000000078'
+ '                                                                                                                        
' + '                                                                                                                                                
' + '                                                                                                             
';
  B3 := '0000003704015E00000003000379002949443A5757572D35444141393' +
'936343542412D333730302D313439343635333733383034362D313A31000131' + '                                                                                                                                                           
' + '                                                                                                                                                                                                                           
';
  B4 := '0000005106025F1F0000000400047B002949443A5757572D3544414139' +
'3936343542412D333730302D313439343635333733383034362D313A3100010001000564000E46696C652E5472616E73706F72740000000064'
+ '                                                                                                            
' + '                                                                                                                                                                       
' + '                                                                                                  
';
  B5 := '000000CF1D0648043001001F0000000500040005000600066E00040001' +
'000600000000040000015C004E1FF80000002D00000002000946494C452E53495A450600000000000122F8000946494C452E4E414D450900077777772E6A70670006000000000054687474703A2F2F3139322E3136382E322E3232373A383136312F66696C657365727665722F49443A5757572D354441413939363435'
+
'42412D333730302D313439343635333733383034362D313A313A313A313A3100186170706C69636174696F6E2F6F637465742D73747265616D62';
  B6 := '000000110C010C000000060004FFFFFFFFFFFFFFFE06';
  B7 := '000000110C010C000000070003FFFFFFFFFFFFFFFE06';
  B8 := '000000110C010C000000080001FFFFFFFFFFFFFFFE06';
  B9 := '000000110C010D000000090000FFFFFFFFFFFFFFFF06';
  B10 := '000000070B01000000000A00';






  self.IdTCPClient1.Host := 'localhost';
           //self.IdTCPClient1.Host:='192.168.2.227';
  IdTCPClient1.Port := 61616;
  IdTCPClient1.Connect();
           //int[]  BBB={398,101,139,59,85,211,21,21,21,21,11};
  try
    sendbytes(b0, 398);
    sendbytes(b1, 101);
    sendbytes(b2, 139);
    sendbytes(b3, 59);
    sendbytes(b4, 85);
    sendbytes(b5, 211);
    sendbytes(b6, 21);
    sendbytes(b7, 21);
    sendbytes(b8, 21);
    sendbytes(b9, 21);
    sendbytes(b10, 11);
    showmessage('send blob');
  except
    IdTCPClient1.Disconnect;
  end;


  IdTCPClient1.Disconnect;
end;
function IntToByte(Value: Integer): Byte; overload;
asm 
       OR     EAX, EAX 
       JNS    @@Positive 
       XOR    EAX, EAX 
       RET

@@Positive: 
       CMP    EAX, 255 
       JBE    @@OK 
       MOV    EAX, 255 
@@OK: 
end;
function TForm1.sendbytes(b: string; L: integer): longInt;
var
  i, j, hh: integer;
  ss, jj: string;
  www: tstringlist;
  buf:array[0..4096] of byte;
begin
  ss := ''; jj := ''; www := tstringlist.Create;
  j := 0;
  IdTCPClient1.SendBufferSize:=L;
  for i := 1 to length(b) do
  begin
    if i > L*2 then
    begin
      break;
    end;
    j := j + 1;
    ss := ss + b[i];
    if j = 2 then
    begin
      hh := hextoint(ss);
      //jj := jj + char(hh);
       //IdTCPClient1.WriteInteger(hh);
       buf[(i div 2)-1]:=IntToByte(hh);
      j := 0;
      ss := '';
    end;

  end;
   IdTCPClient1.WriteBuffer(buf,L);
           //showmessage(jj);
  //self.Memo1.Lines.Add(jj);
  for I := 0 to L-1 do

    jj := jj + inttohex(buf[i], 2);

  www.Text := jj;
  www.SaveToFile('c:\'+inttostr(L)+'.txt');
  www.Free;
end;


end.




--
View this message in context: http://activemq.2283324.n4.nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726459.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Fwd: Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by Tim Bain <tb...@alumni.duke.edu>.
E271828, please see the message below from Tim Bish, the developer who
knows the C++ interface the best. Are you willing to use the test setup you
already have plus a debugger to figure out why this isn't working as
expected?

Tim
---------- Forwarded message ----------
From: "Timothy Bish" <ta...@gmail.com>
Date: May 26, 2017 7:45 AM
Subject: Re: BlobMessage in ActiveMQ-CPP by now 2017
To: "Tim Bain" <tb...@alumni.duke.edu>
Cc:

On 05/26/2017 08:40 AM, Tim Bain wrote:
>
> That's not how I expected it would work. Every message ultimately gets
> converted to the OpenWire protocol, no matter which language you use, so I
> assumed that methods with the same name in the different languages would
> translate to the same OpenWire content, but it sounds like that's not
> happening here.
>
> Tim Bish, could you please explain what users can expect in terms of
> compatibility when using different languages for sending and receiving
> messages? Or is the fact that this particular method isn't compatible
> across languages just a bug?
>
>
> I would suggest some debugging and testing as it's still unclear what's
> been done here.  The plumbing of BlobMessage is mostly not implemented
> outside Java so I don't expect the upload download bits would work, other
> things should but I welcome others who want to contribute to dive in and
> help out with the code and testing.
>
> On May 25, 2017 7:09 PM, "e271828" <16...@qq.com> wrote:
>
>> Both c++ and java have already implemente setStringProperty and
>> getStringProperty.
>> But I found that send blobmessage by useing the setStringProperty in c++
>> which can not been received  by useing the getStringProperty in java.
>>
>>
>>
>> --
>> View this message in context: http://activemq.2283324.n4.nab
>> ble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726595.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>
> --
> Tim Bish
> twitter: @tabish121
> blog: http://timbish.blogspot.com/
>
>

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by Tim Bain <tb...@alumni.duke.edu>.
That's not how I expected it would work. Every message ultimately gets
converted to the OpenWire protocol, no matter which language you use, so I
assumed that methods with the same name in the different languages would
translate to the same OpenWire content, but it sounds like that's not
happening here.

Tim Bish, could you please explain what users can expect in terms of
compatibility when using different languages for sending and receiving
messages? Or is the fact that this particular method isn't compatible
across languages just a bug?

On May 25, 2017 7:09 PM, "e271828" <16...@qq.com> wrote:

> Both c++ and java have already implemente setStringProperty and
> getStringProperty.
> But I found that send blobmessage by useing the setStringProperty in c++
> which can not been received  by useing the getStringProperty in java.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.
> nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726595.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by e271828 <16...@qq.com>.
Both c++ and java have already implemente setStringProperty and
getStringProperty.
But I found that send blobmessage by useing the setStringProperty in c++ 
which can not been received  by useing the getStringProperty in java. 



--
View this message in context: http://activemq.2283324.n4.nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726595.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by e271828 <16...@qq.com>.
I am a chinese.My english is not very good.
I read this english by machine translating.



--
View this message in context: http://activemq.2283324.n4.nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726629.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: BlobMessage in ActiveMQ-CPP by now 2017

Posted by e271828 <16...@qq.com>.
I have solved this problem for the time being.
I first created a new message in parallel in C++, named BlobMessageLi, which
is exactly the same as the 
original TextMessage, but just BlobMessageLi the name is different. My
BlobMessageLi is not the same as 
the original BlobMessage, but it is the same as the original TextMessage.
Then, I replace the message inside the TypeId, ID_ACTIVEMQBLOBMESSAGELI =
29, and 
ID_ACTIVEMQBLOBMESSAGE = 41;
At this point, the setStringProperty sent in C++ can be received normally in
JAVA using the 
getStringProperty.
Then, I modify the original TextMessage getText and setText in parallel to
getRemoteBlobUrl and 
setRemoteBlobUrl.
Then, I add info->getRemoteBlobUrl () and info->setRemoteBlobUrl ()  in
multiple places in 
ActiveMQBlobMessageLiMarshaller.cpp.
Here test, in C++, message>setRemoteBlobUrl
("http://192.168.2.227:8161/fileserver/ID_WWW-5DAA99645BA-3700-1494653738046-1_1_1_1_1");
In JAVA, you can normally open read ActiveMQBlobMessage.getRemoteBlobUrl ()
and 
blobMessage.getInputStream ();
This is to have a premise that the file should be in the server.
At C++, I can upload files in other ways, return a URL, and then
message->setRemoteBlobUrl (myURL) in 
C++;
This basically simulates the expected BlobMessage, but my manager says it's
not safe to say it's 
unsafe.
===================================
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include
<activemq/wireformat/openwire/marshal/generated/ActiveMQBlobMessageLiMarshaller.h>

#include <activemq/commands/ActiveMQBlobMessageLi.h>
#include <activemq/exceptions/ActiveMQException.h>
#include <decaf/lang/Pointer.h>

//
//     NOTE!: This file is autogenerated - do not modify!
//            if you need to make a change, please see the Java Classes in
the
//            activemq-core module
//

using namespace std;
using namespace activemq;
using namespace activemq::exceptions;
using namespace activemq::commands;
using namespace activemq::wireformat;
using namespace activemq::wireformat::openwire;
using namespace activemq::wireformat::openwire::marshal;
using namespace activemq::wireformat::openwire::utils;
using namespace activemq::wireformat::openwire::marshal::generated;
using namespace decaf;
using namespace decaf::io;
using namespace decaf::lang;

///////////////////////////////////////////////////////////////////////////////
DataStructure* ActiveMQBlobMessageLiMarshaller::createObject() const {
    return new ActiveMQBlobMessageLi();
}

///////////////////////////////////////////////////////////////////////////////
unsigned char ActiveMQBlobMessageLiMarshaller::getDataStructureType() const
{
    return ActiveMQBlobMessageLi::ID_ACTIVEMQBLOBMESSAGELI;
}

///////////////////////////////////////////////////////////////////////////////
void ActiveMQBlobMessageLiMarshaller::tightUnmarshal(OpenWireFormat*
wireFormat, DataStructure* dataStructure, DataInputStream* dataIn,
BooleanStream* bs) {

    try {

        MessageMarshaller::tightUnmarshal(wireFormat, dataStructure, dataIn,
bs);

        ActiveMQBlobMessageLi* info =
            dynamic_cast<ActiveMQBlobMessageLi*>(dataStructure);
        info->beforeUnmarshal(wireFormat);
        info->setRemoteBlobUrl(tightUnmarshalString(dataIn, bs));

        info->afterUnmarshal( wireFormat );
    }
    AMQ_CATCH_RETHROW(decaf::io::IOException)
    AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException,
decaf::io::IOException)
    AMQ_CATCHALL_THROW(decaf::io::IOException)
}

///////////////////////////////////////////////////////////////////////////////
int ActiveMQBlobMessageLiMarshaller::tightMarshal1(OpenWireFormat*
wireFormat, DataStructure* dataStructure, BooleanStream* bs) {

    try {

        ActiveMQBlobMessageLi* info =
            dynamic_cast<ActiveMQBlobMessageLi*>(dataStructure);

        info->beforeMarshal(wireFormat);
        int rc = MessageMarshaller::tightMarshal1(wireFormat, dataStructure,
bs);
         rc += tightMarshalString1(info->getRemoteBlobUrl(), bs);
        return rc + 0;
    }
    AMQ_CATCH_RETHROW(decaf::io::IOException)
    AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException,
decaf::io::IOException)
    AMQ_CATCHALL_THROW(decaf::io::IOException)
}

///////////////////////////////////////////////////////////////////////////////
void ActiveMQBlobMessageLiMarshaller::tightMarshal2(OpenWireFormat*
wireFormat, DataStructure* dataStructure, DataOutputStream* dataOut,
BooleanStream* bs) {

    try {

        MessageMarshaller::tightMarshal2(wireFormat, dataStructure, dataOut,
bs );

        ActiveMQBlobMessageLi* info =
            dynamic_cast<ActiveMQBlobMessageLi*>(dataStructure);
            tightMarshalString2(info->getRemoteBlobUrl(), dataOut, bs);
        info->afterMarshal(wireFormat);
    }
    AMQ_CATCH_RETHROW(decaf::io::IOException)
    AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException,
decaf::io::IOException)
    AMQ_CATCHALL_THROW(decaf::io::IOException)
}

///////////////////////////////////////////////////////////////////////////////
void ActiveMQBlobMessageLiMarshaller::looseUnmarshal(OpenWireFormat*
wireFormat, DataStructure* dataStructure, DataInputStream* dataIn) {

    try {

        MessageMarshaller::looseUnmarshal(wireFormat, dataStructure,
dataIn);
        ActiveMQBlobMessageLi* info =
            dynamic_cast<ActiveMQBlobMessageLi*>(dataStructure);
        info->beforeUnmarshal(wireFormat);
        info->setRemoteBlobUrl(looseUnmarshalString(dataIn));
        info->afterUnmarshal(wireFormat);
    }
    AMQ_CATCH_RETHROW(decaf::io::IOException)
    AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException,
decaf::io::IOException)
    AMQ_CATCHALL_THROW(decaf::io::IOException)
}

///////////////////////////////////////////////////////////////////////////////
void ActiveMQBlobMessageLiMarshaller::looseMarshal(OpenWireFormat*
wireFormat, DataStructure* dataStructure, DataOutputStream* dataOut) {

    try {

        ActiveMQBlobMessageLi* info =
            dynamic_cast<ActiveMQBlobMessageLi*>(dataStructure);
        info->beforeMarshal(wireFormat);
        MessageMarshaller::looseMarshal(wireFormat, dataStructure, dataOut);
        looseMarshalString(info->getRemoteBlobUrl(), dataOut);
        info->afterMarshal(wireFormat);
    }
    AMQ_CATCH_RETHROW(decaf::io::IOException)
    AMQ_CATCH_EXCEPTION_CONVERT(exceptions::ActiveMQException,
decaf::io::IOException)
    AMQ_CATCHALL_THROW(decaf::io::IOException)
}






--
View this message in context: http://activemq.2283324.n4.nabble.com/BlobMessage-in-ActiveMQ-CPP-by-now-2017-tp4726457p4726634.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.