Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to understand Storm dubbo service invocation

Shulou Source: shulou.com Published: 2022-05-31 23:21:07 09月14日 Update

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.

Tags: Service middle name commodity project configuration interface file more knowledge program article practical example information right figure address that is work meeting article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info Shulou Technology vpn OPPO Reno