Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand Storm dubbo service invocation

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

What this article shares with you is about how to understand the invocation of Storm dubbo services. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

For a specific example, to illustrate how to invoke dubbo's service.

First, make sure that you introduce the following jar packages:

If your project is not a Mavn project, and you are invoking the dubbo service in Storm. So the above jar packages are several jar packages that you need to put in the project.

Please see the picture on the right, in which I, I made a simple distinction:

Dubbo: all duboo-related jar packages

Lib: all jar packages required by Storm

NotStorm: not the jar package required by Storm

Spring: all jar packages that contain Spring

Second: please be sure to configure the application.xml file. A specific example is as follows.

In the above configuration:

1 reference id: identifies the name of the class in the specific project reference.

2 interface: represents the name of the interface provided to us through the dubbo service, where you usually need to register the name of the interface with the zookeeper service.

3 zookeeper address:

Next, please refer to one of our specific Mini Program: get other information about goods according to the id of goods.

Package test;import java.util.Set;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.wooboo.common.bean.ProductCache;import com.wooboo.common.bean.ProductCategoryCache;import com.wooboo.service.kafka.KafkaServie;import com.wooboo.service.product.service.ProductService;import com.wooboo.service.productcategory.service.ProductCategoryService;public class TestDubbo {public static ClassPathXmlApplicationContext context = null Static {context = new ClassPathXmlApplicationContext (new String [] {"applicationContext.xml"}); context.start () } public static void main (String [] args) throws Exception {/ / Service ProductService productService = (ProductService) context .getBean ("productCacheService"); / / Service ProductCategoryService categoryService = (ProductCategoryService) context .getBean ("productCategoryService") Long goodsid = 627L; ProductCache cache = productService.getProduct (goodsid); / / Long productCategoryId = cache.getProductCategoryId (); / / ProductCategoryCache categoryCache = categoryService .getProductCategory (productCategoryId); long parrent = categoryCache.getParent () Set child = categoryCache.getChildren (); / / System.err.println (parrent);} public static void p (Object o) {System.err.println (o.toString ());}}

In this Mini Program, please pay attention to our local

ProductCategoryService

This class class needs to exist locally. During the call to the method, what is passed in getBean () is the id name that we configured in the xml file.

At this point, a small service call is complete.

The above is how to understand the invocation of Storm dubbo services. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report