首页 \ 问答 \ JMS是否有队列偷看的概念?(Does JMS have a concept of a queue peek?)

JMS是否有队列偷看的概念?(Does JMS have a concept of a queue peek?)

从一般的计算机科学角度来看 - 当我们从逻辑意义上考虑一个队列时 - 我们认为能够“窥视”队列中的第一个项目。

当我查看JMS API时 - 它有一个MessageListener - 它有一个OnMessage()方法。 这感觉有点像“不要打电话给我们 - 我们会打电话给你。”

JMS是否有队列偷看的概念?


From a general Computer Science perspective - when we think of a Queue in a logical sense - we think of being able to 'peek' the first item in the queue.

When I look at the JMS API - it has a MessageListener - which has an OnMessage() method. This feels a little bit like "don't call us- we'll call you."

Does JMS have a concept of a queue peek?


原文:https://stackoverflow.com/questions/15317207
更新时间:2022-05-22 19:05

最满意答案

第一个是函数表达式 ,第二个是函数声明 (它最后不需要分号,顺便说一下)。 然而,区别与构造函数无关,并且适用于普通函数。

您可能知道,函数是javascript中的第一类值。 其中一个暗示是可以将函数分配给变量。 因此,就像您可以为变量分配数字(例如var pi = 3.14 ),您可以将函数分配给变量, var add = function(a,b) {return a + b} 。 这就是你的第一个声明所做的,它创建一个函数(实现为闭包),然后在变量Person存储对它的引用。 您可以将第二个视为第一个的快捷方式。

有关语法细节,请查看规范的§14.1


The first is a function expression, the second a function declaration (it doesn't need the semicolon at the end, btw). The distinction is not tied to constructors, however and applies to ordinary functions.

As you probably know, functions are first-class values in javascript. One of the things that implies is that functions can be assigned to variables. So, just like you can assign numbers to variables (e.g. var pi = 3.14), you can assign functions to variables, var add = function(a,b) {return a + b}. That's what your first declaration does, it creates a function (implemented as a closure) and then stores the reference to it in the variable Person. You can think of the second one as a shortcut for the first.

For the syntactical details, check out §14.1 of the spec.

相关问答

更多
  • 最重要的区别:当你实例化一个对象时,它的构造函数将被调用,而调用一个方法总是可选的。 因此,您可能会忘记调用您的初始化方法,并无法正确初始化所有内容。 例如,所有这些实例化对象的常规方法都会调用构造函数 Foo* p = new Foo(); Foo p; 或者,如果您有强制参数,请不要定义默认构造函数,而是需要使用参数构造: class Foo { private: Foo(); public: Foo(int param1, double param2) }; 这样做的好处是在实例化类之 ...
  • 私有构造函数意味着用户不能直接实例化一个类。 相反,您可以使用“ Named Constructor Idiom”创建对象,您可以在其中创建并返回类的实例的static类函数。 命名构造函数成语用于更直观地使用类。 C ++ FAQ提供的示例是可用于表示多个坐标系的类。 这是直接从链接拉。 它是一个表示不同坐标系中的点的类,但它可以用于表示矩形和极坐标点,因此为了使用户更直观,不同的函数用于表示返回的Point表示的坐标系。 #include // To get ...
  • 如果您没有与对象相关联的行为(即如果对象只是数据/状态的容器),我将使用一个对象字面值。 var data = { foo: 42, bar: 43 }; 应用KISS原则 。 如果您不需要任何超出数据容器的数据,请使用简单的文字。 如果要向对象添加行为,可以在构造过程中使用构造函数,并在构造过程中向对象添加方法,或者给您的类做一个原型。 function MyData(foo, bar) { this.foo = foo; this.bar = bar; thi ...
  • 基本的区别在于,使用new关键字(这将导致JavaScript自动创建一个新对象, this对象设置在该对象的函数内,并返回该对象)的构造函数: var objFromConstructor = new ConstructorFunction(); 工厂函数被称为“常规”函数: var objFromFactory = factoryFunction(); 但是,它被认为是一个“工厂”,它需要返回一个新对象的实例:如果它刚刚返回一个布尔值或者某个东西,你不会将其称为“工厂”函数。 这不会像new一样自动 ...
  • 这称为初始化列表,用于初始化类成员。 它既可以作为简写,也可以初始化没有默认构造函数的成员。 例如: #include using namespace std; class Foo { public: Foo(int x) { cout << "Foo(" << x << ")" << endl; } }; class Bar : public Foo { Foo member; public: Bar() { /* error */ } }; 这会产生错 ...
  • function editor(){ /*...*/ } Object.assign(editor, { document(){//this is a new shortform for methods ;) //whatever } //... }); 问题是无论何时将对象文字分配给编辑器 ,您都将覆盖该函数: editor = {...}; 由于无法构造具有属性的函数,我们需要先创建一个函数,然后将属性分配给它(就像我上面所做的那样)。 function editor(){ / ...
  • 构造函数为对象赋予了一种身份感。 它本质上是如何创建它可以重复使用的蓝图。 它与经典OOP中的类非常相似并经常混淆。 如果你经常有一堆“汽车”对象,并且有通常与所有汽车一起使用的方法或属性,你可以创建一个Car构造函数来帮助封装它。 function Car(numPassengers) { this.numPassengers = numPassengers; } Car.prototype = { accelerate: function () { // blah }, ...
  • 第一个是函数表达式 ,第二个是函数声明 (它最后不需要分号,顺便说一下)。 然而,区别与构造函数无关,并且适用于普通函数。 您可能知道,函数是javascript中的第一类值。 其中一个暗示是可以将函数分配给变量。 因此,就像您可以为变量分配数字(例如var pi = 3.14 ),您可以将函数分配给变量, var add = function(a,b) {return a + b} 。 这就是你的第一个声明所做的,它创建一个函数(实现为闭包),然后在变量Person存储对它的引用。 您可以将第二个视为第一 ...
  • 就构造函数而言,没有区别。 JavaScript中的所有函数都可以作为构造函数调用(无论它们是否抛出错误都是完全不同的问题)。 不同之处在于声明函数的方式。 第一个声明是一个需要执行的变量。 第二个声明是一个悬挂的功能。 JavaScript中的var foo和function foo语句被提升到其结束范围的顶部(最近的function父级)。 这意味着: (function () { //closure for scope doStuff(); var foo = bar; }()); 实际上是 ...
  • 根据java 文档 枚举类型的构造函数必须是包私有或私有访问。 但是加入JLS 如果没有为枚举类型的构造函数指定访问修饰符,则构造函数是私有的。 所以包私有和私有没有区别。 According to java docs The constructor for an enum type must be package-private or private access. but Accroding to the JLS If no access modifier is specified for the co ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • 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)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置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])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)