about ZeroMQ

Jul 2, 2012 at 7:22 AM
Edited Jul 2, 2012 at 7:26 AM

hi rpgmaker,

i  want to use  other transport  to receive message after subscribing to a topic, can you show me some samples.  ZeroMQ  is  default transport  way,right?   When i  send  some chinese characters  with pservice ,there is some errors.

Does Phoenix.ZeroMQConnectors.dll has source code?

thank you

Coordinator
Jul 2, 2012 at 1:10 PM

There is also no default transport. ZeroMQ is not used as a transport to receive messages, It is only used to communicate to the entry point(s) of the service bus. The receiving transport are listed on the homepage. which are the following: WCF(NetTcp), MSSQL, WP7 Push Notification, MSMQ, RabbitMQ, Redis, TCP, WebService, HTTP, Email. 

Phoenix.ZeroMQConnectors.dll does has source code which is not checked into the current repository, but I don't think ZeroMQ is your problem.

When you subscribe to a message, you specify what transport you wish to use to receive your messages just as shown in the sample below. Most of the sample codes are setup with subscribers that uses TCP, since it requires no additional installation such as rabbitmq in order to be able to run them.

 

Can you post the error message you are receiving when using chinese character here, the problem should simply be because of the encoding of the transport been used to receive the messages. Can you also post the code you have on pastebin and link it here. And if you are testing with the sample code, can you point me to the one you are using.

 

As for sample using different transport, you can refer to the links below.

Tcp Sample Code( ChatApp, Most of the samples)

http://pservicebus.codeplex.com/wikipage?title=How%20to%20subscribe%20to%20a%20topic&referringTitle=Documentation .

For WCF(NetTcp) transport, there is NetTcpCommunication sample(http://pservicebus.codeplex.com/SourceControl/changeset/view/64929b2b97e4#pServiceBus%202.0.0%2fSamples%2fNetTcpCommunication%2fNetTcpCommunication%2fProgram.cs),

For WP7 Push Notification I have a WP7 Chat App(http://pservicebus.codeplex.com/SourceControl/changeset/view/64929b2b97e4#pServiceBus%202.0.0%2fSamples%2fWP7ChatApp%2fWP7ChatApp%2fMainPage.xaml.cs),

For Web Service/Http  Sample(http://pservicebus.codeplex.com/SourceControl/changeset/view/64929b2b97e4#pServiceBus%202.0.0%2fSamples%2fInvokeWebService%2fInvokeWebService%2fProgram.cs)

For RabbitMQ (JS Web Chat:http://pservicebus.codeplex.com/SourceControl/changeset/view/64929b2b97e4#pServiceBus%202.0.0%2fSamples%2fJS%20API%20WebChat%2fScripts%2fchat.js  )

Jul 4, 2012 at 2:19 AM
Edited Jul 4, 2012 at 2:24 AM

Hi rpgmaker , thank you for your  quick reply.

Here is my code:

 

Public Sub SendMessage()                     

  Dim dao As New MessageTemplateDAO          

  Dim dtoPersonList As New List(Of ESBTaskPersonDTO)          

  dtoPersonList = dao.GetPersonTask()                  

  If dtoPersonList.Count > 0 Then              

  Dim sendtopic As String = "sendtopic"              

  Dim Address As String = "address"                      

    ESB.ReThrowException(True)            

    ESB.ConfigWithAddress(System.Configuration.ConfigurationManager.AppSettings(Address))                             

    Dim stopic1 As String = System.Configuration.ConfigurationManager.AppSettings(sendtopic)                       

    If Topic.Select(stopic1).State = ObjectState.InValid Then                

    Dim mTopic As Topic = Topic.[New](stopic1)                  

    mTopic.SetMessageExpiration(TimeSpan.FromDays(100))                  

   mTopic.Register()            

    End If              

    Try                    

       Dim aa As Topic = Topic.Select(stopic1)                

       aa.SetMessageExpiration(TimeSpan.FromDays(100))
       aa.PublishMany(Of ESBTaskPersonDTO)(dtoPersonList)                                 

   Catch ex As Exception              

       AppLog.Info(Nothing, MethodBase.GetCurrentMethod, inSqlText:=Nothing, inMessage:=ex.Message)          

      End Try                      

 End If                   

End Sub

-------------------------------------------------------------------------------------------------------------------------------------

Dim esbdto As New ESBTaskPersonDTO  
 
              esbdto.ESBTempEventUID = Guid.NewGuid()  
              esbdto.PersonalTaskUID = Guid.NewGuid()  
              esbdto.PlanEndDate = "2012-06-18"  
              esbdto.PlanStartDate = "2012-12-21"  
              esbdto.ProjectName = "电饭锅"  
              esbdto.StaffCode = "101724"  
              esbdto.TaskName = "25"  
              esbdto.TaskStatus = "01"  
 

            esbdto.Type = "01"

            dtoPersonList.add(esbdto )

 

----------------------------------------------------------------------------------------------------------------------------------------

When it goes to    "aa.PublishMany" ,the error happens.

internal static void Execute(Action<IMessageBus> action) {  
              var messageBus = MessageBus;  
              try {  
                  action(messageBus);  
              } catch (Exception) {  
                  LastESBEndpoint.IsAvailable = false;  
                  CallReconnectCallback();  
                  Execute(action);  
              }  
          }  

 

在 System.Text.UTF8Encoding.GetBytes(String s, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex)  
     在 MessageShark.CustomBinary.StringToByteArray(String value)  
     在 MessageShark.CustomBinary.WriteObjectToBuffer(CustomBuffer customBuffer, Object value, Int32 tag, Boolean isTargetCollection)  
     在 IZeroMQCommandSerializer.WriteTopicInfo(CustomBuffer , TopicInfo , Int32 , Boolean )  
     在 IZeroMQCommandSerializer.WriteBusMessage(CustomBuffer , BusMessage , Int32 , Boolean )  
     在 BusMessageSerializer.ISerializer.Serialize(BusMessage )  
     在 MessageShark.MessageSharkSerializer.Serialize[T](T value)  
     在 Phoenix.ZeroMQConnectors.SerializationExtension.Serialize[T](T obj)  
     在 Phoenix.ZeroMQConnectors.ZeroMQSender.Send[TCommand](TCommand command)  
     在 PServiceBus.Services.Gateway.Runtime.ZeroMQMessageBus.PublishTopic(Topic topic) 位置 C:\Users\DPMSSystem\Desktop\BatchBase\PServiceBus.Services.Gateway\Runtime\ZeroMQMessageBus.cs:行号 105  
     在 PServiceBus.Services.Gateway.Runtime.Topic.<InternalPublish>b__5(IMessageBus connector) 位置 C:\Users\DPMSSystem\Desktop\BatchBase\PServiceBus.Services.Gateway\Runtime\Topic.cs:行号 335  
     在 PServiceBus.Services.Gateway.Runtime.ESB.Execute(Action`1 action) 位置 C:\Users\DPMSSystem\Desktop\BatchBase\PServiceBus.Services.Gateway\Runtime\ESB.cs:行号 131  
 

 

 waiting for your reply!!! thank you very much


Coordinator
Jul 4, 2012 at 3:13 AM

The bug is from MessageShark Library. Sorry :) I just updated it. So you will need to download the change from the source control and rebuild using the build.cmd file. Then you can use the newly generated PServiceBus.dll in the Binaries folder.

Let me know if you have any other issue

Coordinator
Jul 4, 2012 at 3:32 AM

Btw, you should be only call SetMessageExpiration on the topic prior to calling Publish or PublishMany method. You should not be calling it before registering a topic because it does nothing at that point.

Jul 5, 2012 at 8:19 AM
Edited Jul 5, 2012 at 8:19 AM

      The new MessageShark.dll   can send chinese charaters.  
   
  But when ESB send messages  to subscriber  , error happens on  Src\PServiceBus.Core\Runtime\Extensions\ObjectExtension.csSerialize<T>(this T obj)  

And we do some changes like the following:  
-------------------------------------------------------------------------------------------------- 

 public static byte[] Serialize<T>(this T obj) where T : class {  
              if (obj == null) return null;  
              if (typeof(T) == StringType) {  
                  //var value = obj as string;  
                  //var size = UTF8.GetByteCount(value);  
                  //var buffer = new byte[size];  
                  //UTF8.GetBytes(value, 0, size, buffer, 0);  
                  //return buffer;  
                  var value = obj as string;  
                  var buffer = UTF8.GetBytes(value);  
                  return buffer;  
              }  
              return MessageSharkSerializer.Serialize(obj);  
          }

-----------------------------------------------------------------------------------------------------  
 
  Btw,"&"  character  still has problem on send and receiving .

   

Coordinator
Jul 5, 2012 at 11:22 AM

Thanks for finding the problem :)

I fixed the problem with the Serialization for String in that method. I still used the GetBytes by replacing size with value.Length. The "&" should not be a problem. You will need to uninstall psb first and compile the current source code in the repository and then install it. The reason is because Tcp, Rabbit, and Redis provider uses the serialize method with a string and if you simply update the client dll and not update the server dll then you will end up with two different serialization which result in "&" not working because of how bytes are been counted.

Let me know of any more finding. Thanks

Coordinator
Jul 5, 2012 at 11:58 AM

Btw, what transportformat is your application using that made & a problem? Xml, json, csv, text ?

Thanks

Jul 6, 2012 at 1:47 AM
Edited Jul 6, 2012 at 6:33 AM

Xml  format

And i am tring to reinstall psb on a new server.

Waiting for my good news.

 

best regards thanks:)

 

Coordinator
Jul 6, 2012 at 4:13 AM

You were right, It is unfortunate that "&" truly does not work because of how Xml parsing work with "&". I find a solution to properly serializing the & and other invalid xml character.

 

Thanks

Coordinator
Jul 6, 2012 at 5:13 AM

Btw, I manage to fix the Invalid Xml character problem :). And I have checked it in and if you want the fix you will need to recompile from source control. And install the new version. Have fun

Jul 16, 2012 at 8:21 AM

hi  rpgmaker,

Here is a another problem that confuse us......When we change the ip address(ESB server),it can not work anymore.

Any configuration about it?  

Coordinator
Jul 16, 2012 at 11:33 PM

What do you mean? "We changed the ip address(ESB Server), it can not work anymore"? Can you give an example or context to what you are describing?

 

Thanks

Jul 17, 2012 at 7:48 AM

hi  rpgmaker.

I have a another problem .

That is SQL Server2008 how to connect to the ESB.

Need to modify which configuration file.

Jul 17, 2012 at 7:55 AM

“Here is a another problem that confuse us......When we change the ip address(ESB server),it can not work anymore.

Any configuration about it?”.

This problem does not exist.

Thanks.

Coordinator
Jul 17, 2012 at 10:53 AM
Edited Jul 17, 2012 at 1:11 PM

If it is about message store and logging. Read this documentation. http://pservicebus.codeplex.com/wikipage?title=How%20to%20update%20the%20database%20server%20for%20message%20storage%20service&referringTitle=Documentation