如何实现与J2EE应用程序的异步处理(How to implement asynchronous processing with J2EE application)
我有一个每天大约有2k个并发用户的企业应用程序。 这些用户处理客户呼叫,因此应用程序速度至关重要。
当用户打完电话时,他们会提交所有捕获的信息。 此提交可能需要10-45秒。
我正在研究如何从用户那里获得延迟。
我们有一个在IE中运行的Web前端,后端是一个运行在单个EJB上的沉重的Java。
我希望这个提交过程是异步的,因为一旦用户提交请求,他们不必等待提交完成,然后再继续下一位客户。 这是目前实施的。
最初我只想到产生另一个线程来处理提交,但这对EJB来说是不可能的。
我能想到的其他选项是使用JMS或SIB,
最好的解决方案是什么? 我还缺少另一种选择吗?
I have an enterprise application with around 2k concurrent users every day. These users handle customer calls so application speed is of vital importance.
When a user is wrapping up a call they commit all the information they captured. This commit can take anywhere from 10-45 seconds.
I am looking into ways to take the delay away from the user.
We have a web front end running in I.E. the backend is heavy java running on a single EJB.
I wanted to make this commit process asynchronous in that once the user submits the request they don't have to wait for the commit to finish before going on to the next customer. This is what is currently implemented.
Originally I was thinking of just spawning another thread to handle the commit but that's a no no with EJB's.
Other options I can think of would be using JMS or SIB,
What would the best solution be? Is there another alternative I am missing?
原文:https://stackoverflow.com/questions/2008720
最满意答案
我读这个的方式,你试图将这棵树转换成只有Id,Name和Children的节点树。 在这种情况下,我认为它的方式是清洁节点。
要清理节点:
- 使用原始节点的Name和Id创建节点。
- 将新节点的Children设置为原始节点的子节点的已清理版本。 (这是递归调用。)
在代码中,那将是:
def clean_node(node): return { 'Name': node['Name'], 'Id': node['Id'], 'Children': map(clean_node, node['Children']), } >>> print map(clean_node, data) [{'Name': 'x', 'Children': [], 'Id': 'y'}, {'Name': 'xx', 'Children': [{'Name': 'xyx', 'Children': [], 'Id': 'yxy'}], 'Id': 'yy'}]
我发现像这样打破递归问题更容易 - 尝试使用全局变量会很快变得非常混乱。
The way I read this, you're trying to convert this tree into a tree of nodes which only have Id, Name and Children. In that case, the way I'd think of it is as cleaning nodes.
To clean a node:
- Create a node with the Name and Id of the original node.
- Set the new node's Children to be the cleaned versions of the original node's children. (This is the recursive call.)
In code, that would be:
def clean_node(node): return { 'Name': node['Name'], 'Id': node['Id'], 'Children': map(clean_node, node['Children']), } >>> print map(clean_node, data) [{'Name': 'x', 'Children': [], 'Id': 'y'}, {'Name': 'xx', 'Children': [{'Name': 'xyx', 'Children': [], 'Id': 'yxy'}], 'Id': 'yy'}]
I find it's easier to break recursive problems down like this - trying to use global variables turns simple things very confusing very quickly.
相关问答
更多-
正如您所观察到的, config_file是一个列表,而不是字典。 您需要访问列表中的第一个字典,然后调用键"the_dict" ,然后调用"words"来获取单词列表: my_words = config_file[0]["the_dict"]["words"] config_file is a list, not a dictionary, as you have observed. You will need to access the first dictionary in the list, a ...
-
如果您有兴趣在不使用中介存储的情况下创建一个新的dict:(这更快,在我看来,比使用dict.items()更干净) dic2 = dict(dic0, **dic1) 或者如果您乐意使用其中一个现有的术语: dic0.update(dic1) If you're interested in creating a new dict without using intermediary storage: (this is faster, and in my opinion, cleaner than us ...
-
如果我理解你想要做什么,所有这些都可以通过以下代码实现: def dict_sum(d1, d2): if d1 is None: return d2 if d2 is None: return d1 if isinstance(d1, list) and isinstance(d2, list): return list(set(d1 + d2)) try: return d1 + d2 except TypeError: ...
-
在Python中从json文件中读取包含整数的多个词典(Read multiple dictionaries containing integers from json file in Python)[2023-05-12]
为什么使用json,如果你没有json,只想知道你有多少个dicts? 尝试这个 with open( 'filename.json', 'r' ) as f : data = f.read() count = len( data.split('}{') ) Why using json if you don't have json and just want to know how many dicts you have? Try this with open( 'filename.json' ... -
我读这个的方式,你试图将这棵树转换成只有Id,Name和Children的节点树。 在这种情况下,我认为它的方式是清洁节点。 要清理节点: 使用原始节点的Name和Id创建节点。 将新节点的Children设置为原始节点的子节点的已清理版本。 (这是递归调用。) 在代码中,那将是: def clean_node(node): return { 'Name': node['Name'], 'Id': node['Id'], 'Children': map ...
-
您需要扩展列表检查每个值。 现在你无法根据词典的name项合并它们: def merge(lsta, lstb): for i in lstb: for j in lsta: if j['name'] == i['name']: j.update(i) break else: lsta.append(i) for k,v in dictb.items(): ...
-
如果你正在尝试使用ReturnedMonitors()创建一个生成器函数,那么你错误地创建了它,当你从函数return它时,你需要使用yield关键字,如果你需要在`分别监视列表,你应该循环它们并单独产生。 示例 - def ReturnedMonitors(): listOfChecks = json.loads(connectSite('GET','')) for i in listOfChecks['data']: while i['display_name'].sta ...
-
Python3:根据其他词典添加到列表中的词典(Python3: Add to dictionaries in list, based on other dictionaries)[2024-01-19]
output = [dict([*p.items(), ['colleagues', [q for q in input if p != q]] ]) for p in input] 您可以通过使用sets和inputset - set(p)来加快速度。 整个dict([*p.items(), [k, v]])是一种黑客,可以使用额外的键值对创建一个新的dict,而不必使用语句。 它几乎相当于dict_with_new_pair(p, k, v ... -
当发件人端的数据结构化为命名字段的集合时,您将获取每组命名字段的字典。 在这种特殊情况下,看起来最外面的对象有一个字段,它是一个对象的集合(即列表或数组),每个对象都有一个name和description 。 换句话说,发件人会向您发送以下内容: @interface Item @property (readwrite, copy) NSString* name; @property (readwrite, copy) NSString* description; @end @interface MyOb ...
-
我实现了一个带有dict和__missing__函数的树。 如果节点不存在,则添加节点 import json class CategoryNode(dict): def __missing__(self,key): self[key] = CategoryNode() return self[key] def add_item(self, item): self[item['bigCtgr']][item['smaCtgr']][item[ ...