首页 \ 问答 \ 两个独立应用之间的消息通信(Message Communication between two Independent Applications)

两个独立应用之间的消息通信(Message Communication between two Independent Applications)

我有一个要求,即Groovy应用程序应该将事件通知发送到另一个Java Web应用程序,而不是在Web界面上显示该数据。

  • 我不想使用像ActiveMQ或RabbitMQ这样的队列,因为这会引入一个额外的层,如果不存在其他解决方案,将使用它。

  • 我已经分享了一个想法,即我应该从我的Java应用程序中公开一个Web服务,它将由第一个应用程序使用,然后发送到Web服务的数据将在第二个应用程序中被接收并以某种方式显示在其上网络界面。

我不确定这将如何工作,即如何在其Web界面上显示第二个应用程序的Web服务中接收的数据。

请帮我找出适合这项任务的正确解决方案。


I have a requirement where a Groovy Application is supposed to send event notifications to another Java Web Application Which will than display that data on web interface.

  • I don't want to use Queues like ActiveMQ or RabbitMQ because this will introduce an extra layer and will be used if no other solution exists.

  • An idea have been shared with me that I should expose a web-service from my Java application, which will be consumed by the first application, and the data sent to the web-service will be then received in second application and somehow displayed on it's web interface.

I am not sure how this will work i.e how the data which is received in web-service of second application will be displayed on its web interface.

Kindly help me to figure out the right solution for this task.


原文:https://stackoverflow.com/questions/28277603
更新时间:2023-07-07 06:07

最满意答案

如果您需要解析的是一个字符串数组,那么您可以执行以下操作:

string trimmedAnswer = Lib.Arr().Trim(); // Remove whitespaces from the beginning and end
trimmedAnswer = trimmedAnswer.Substring(1, trimmedAnswer.Length - 1); // Remove [ and ] characters
string[] Answer = trimmedAnswer.Split(",").Select(s => s.Trim()).ToArray(); // Split every element by the commas, and remove any whitespaces 

但是如果你需要解析更复杂的jsons,那么你需要这样的答案: https ://stackoverflow.com/a/24891561/2420998


If all you need to parse is an array of strings, then you can do something like this:

string trimmedAnswer = Lib.Arr().Trim(); // Remove whitespaces from the beginning and end
trimmedAnswer = trimmedAnswer.Substring(1, trimmedAnswer.Length - 1); // Remove [ and ] characters
string[] Answer = trimmedAnswer.Split(",").Select(s => s.Trim()).ToArray(); // Split every element by the commas, and remove any whitespaces 

But if you need to parse more complicated jsons, then you need something like this answer: https://stackoverflow.com/a/24891561/2420998

相关问答

更多
  • 使用二维散列图或数组或其他类型的直接访问数据结构,在其中存储(布尔)或特定类型的多少(int)卡在您的手中。 例如: [ '9H', '10S', 'KD', '9D', '7D', 'QC', 'JC', '7C' ] => | A K Q J 10 9 8 7 6 5 4 3 2 --+-------------------------------------- C | 0 0 1 1 0 0 0 1 0 0 0 0 0 D | 0 1 0 0 ...
  • 使用 @Html.Raw(JsonConvert.SerializeObject(extentions)) Html.Raw确保参数不会被html编码,因此你不会得到" 而不是"再 Use @Html.Raw(JsonConvert.SerializeObject(extentions)) Html.Raw ensures that argument will not be html-encoded, so you won't get " instead of " anymore.
  • 假设您的JSON位于字符串变量json ,获取JSON字符串数组的最短方法是: JArray.Parse(json).Select(o => JsonConvert.SerializeObject(o)).ToArray(); 然而,获得JObject的最快方法是 foreach (JObject jObject in JArray.Parse(json)) { // do something with jObject } Assuming your JSON is in a string v ...
  • 没有其他答案处理意外的输入...执行此操作的方式是使用.reduce()和类型检查。 var myArray = [ [[1, 2, 3], 'a'], // [1] is valid property name, [0] valid value ['b', 2, 5, 2], // [0] is valid property name, [1] valid value ['c', undefined], // [0] is valid property name, [1] invalid ...
  • 我更喜欢这种方式。 没有手动循环,你也可以使用相当复杂的视图模型(只要你的类型中没有递归引用)。 var myArray = @Html.Raw(Json.Encode(Model.Names)) $("#tags").autocomplete({ source: myArray }); I prefer this way. No manual Looping, and you can do this with fairly complex viewmodels as well (as lon ...
  • 使用正则表达式用双引号替换单引号,然后JSON.parse将正常工作: JSON.parse(my_data.replace(/\'/g,"\"")); 单引号不是JSON数据的有效字符。 Replace the single quotes with double quotes using regex, then JSON.parse will work fine: JSON.parse(my_data.replace(/\'/g,"\"")); Single quotes are not valid ch ...
  • 如果您需要解析的是一个字符串数组,那么您可以执行以下操作: string trimmedAnswer = Lib.Arr().Trim(); // Remove whitespaces from the beginning and end trimmedAnswer = trimmedAnswer.Substring(1, trimmedAnswer.Length - 1); // Remove [ and ] characters string[] Answer = trimmedAnswer.Split ...
  • 方法1:在drawChart()中形成图表数据 使用System.Web.Script.Serialization; 1)构建jsonobj public string GetLocality() { string[] locality = new string[] { "Loc_A", "Loc_B", "Loc_C", "Loc_D", }; //long[] frequency = new long[] { 10, 20, 10, 80 }; J ...
  • 相关文章

    更多

    最新问答

    更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)