How to run Kafka Server with Producer and Consumer in Windows - Six steps Practical guide

In this post, we will learn that how to install and use Kafka server along with producer and consumer clients message exchange. This guide is based on practical only (no theory). For theory you can see other resources. This is the step by step practical guide that how to run Kafka on windows environment.

Step 1: Download and Extract Kafka in your desired directory:

1. Go to the link Apache Kakfa download and download. (I have download binary version 2.13)
2. Extract the .tgz file into any suitable location.




I have extracted my Kafka installation into C drive insdie Apachekafka Folder. 


Step 2: Install Java run-time and Save its path in environment variable.

1. Go to the link and install java runtime
2. After installation, open Environment variable from my computer properties and add JAVA_HOME variable and provide your java runtime installation path.

Java runtime installation path provided in a new environment variable named JAVA_HOME. 
3. In environment variable, select path, click on edit button and add this string  “;%JAVA_HOME%\bin”
4. Go to command line and test "java -version". If you are not getting java installed version then see

How to solve "npm not recognized as internal or external command"


Step 3: Run Apache Zookeeper and Kafka Server

1. Make a batch file next to your Kafka folder. This batch file will run Zookeeper server. Add below line and run the batch file

start kafka_2.13-2.4.1\bin\windows\zookeeper-server-start.bat kafka_2.13-2.4.1\config\zookeeper.properties

Note:In above batch file command, kafka_2.13-2.4.1 is my Kafka installation folder name put your folder name in both location.

2. Make a batch file for running the Kafka Server and Run the batch file

start kafka_2.13-2.4.1\bin\windows\kafka-server-start.bat kafka_2.13-2.4.1\config\server.properties

Note:In above batch file command, kafka_2.13-2.4.1 is my Kafka installation folder name put your folder name in both location.

Two batch files have created in order to run Zookeeper and Kafka Server. Whenever you want to run Kafka server, you first need to start zookeeper server.

Step 4: Create A Topic

In order to send message from Producer to consumer, you first need to create a topic. Later both producer and consumer will subscribe the topic and send and receive messages.

1. Go to Kafka installation directory, then Bin\Windows, and open command prompt form here and type below lines. You can write your desired name instead of YourTopicName
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic YourTopicName
A topic with name "YourTopicName" has created successfully. 

Step 5: Start Producer

Kafka provides you message producer that will produce message for a specific topic.
1. Go to kafka installation directory, then Bin\Windows, and open command prompt form here and type below lines. 
kafka-console-producer.bat --broker-list localhost:9092 --topic TopicToSubscribe
Note: TopicToSubscribe is the topic name where you want to send messages, in our case it should be YourTopicName
2. Hit enter to start the producer

Step 6: Start Consumer

As name suggest consumer will get the messages from producer. 
1. Go to kafka installation directory, then Bin\Windows, and open command prompt form here and type below lines. 
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic TopicToSubscribe
Note: TopicToSubscribe is the topic name from where you want to gete messages , in our case it should be YourTopicName
2. Hit enter to run the consumer
3. Now go to Producer command line, and type any message and enter
4. View the Consumer command line you will get the message.


Unity vector graphics package missing solution

Unity Vector graphic package is in the preview stage currently so you need to check one more setting in order to view the package in the package manager window. First of all, you need to open package manager window from the Window menu then click on advanced setting and check show preview packages.


Unity Webgl Issues and Solutions

During my extensive interaction with unity WebGL, I found different things that are difficult to handle in unity WebGL or Unity Webgl has some serious limitations (But nevertheless I have managed to stream large 3D area in unity WebGL with asset bundles). I have made this post in order to show you Unity3D WebGL issues sheet and if you are interested to see what technologies or toolchain Unity WebGL using behind the Scene then check this post. So, without a particular order here is the list of unity webgl limitations with relevant references for your further research. 



1. You cannot use Threads in unity WebGL. Here is the error that you will get when thread try to start:
SystemException: Thread creation failed.
UnityLoader.js:4   at System.Threading.Thread.StartInternal (System.Security.Principal.IPrincipal principal, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
GameDev Question
Unity Forum
Unity Webgl Doc
Update: Unity claim that in Version 2019.1.0 they have added multiple Multithreading support but it was not working according to my test and now I also find this that there was bug with the problem which has fixed in Unity 2020.1.0 and Unity 2019.4.7 (untested)

2. If you are continuously pressing any keyboard input key and meanwhile you lost focus to WebGL canvas in the browser, the input will still work even after releasing the key. The situation may get worst in the Edge browser.
Ref:
SE Question
Maybe resolved in Unity 2019.3.0 but I have tested and still the same problem is happening.

Unity Tips and Tricks (Unity Shader Tips and Tricks) Part V

In this post, we gather different tips and tricks related to Unity Shaders.

Unity Shader Tips and Tricks











See Also:

Game Pause on error in Unity3d

For debugging purposes, you may require to pause the game on an error so that you can inspect the game situation. For this reason, you can follow these steps:

1. Write an error log in block of the code

    Debug.LogError("Exception occured");

And before running the editor open console and hit Error Pause in the console log.


The game will pause as any error occurred in the console.

  

store image in database or path which better?

There are different pros and cons of saving images file into database.

Saving Image file in Database

Pros:

If you want to save and secure sensitive/confidential Images like employee face images.
Deleting the file will delete the image too.
Database backup will automatically backup the images too.

Cons:

Slow access to the image and require more resources on the server.
The database grows quickly consequently database backup will require more time.

Saving Image  in File System


Pros:

Enable quick access to the image, Webserver easily/quickly provide the file.
Easily viewable on the server through image viewer/browse.

Cons:

Deleting the record will require to delete the file separately.
Low security of image

Ref:


  1. https://teamtreehouse.com/community/storing-image-in-database-compare-with-storing-at-the-folder-server
  2. https://www.quora.com/Difference-in-storing-image-in-database-table-vs-storing-image-in-folder-and-save-its-path-in-database-Which-is-better-and-why-PHP
  3. https://habiletechnologies.com/blog/better-saving-files-database-file-system/

How to send email form Unity3d and C# using gmail

Here are the 7 steps guide to send an email from your unity game using Gmail service. With gamil mail service you can send email in unity3d.

Steps for Gmail Account:

1. Login to Gmail Account
2. Go to at this location https://myaccount.google.com/security
3. Go to the Less secure app access section and Turn on Allow less secure app access (see image below)


Steps for Unity

4. Create a Unity project (or in your existing project) Make a script with SendEmail name and Copy Below code.
5. Attach the script with any game-object in your hierarchy.
6. Provide the credential in the inspector in the script (like your account and password and receiver account, message body, etc)
7. Run the game, it will send the email to the desired address in the start function

Note: If your system is behind a proxy then, email may not be sent and throw an exception. 

How To make Responsive Unity UI Canvas for multiple aspect ratio

How To Get Dropdown Text in Unity3d

How To Get Get Dropdown value in Unity3D

Unity3d How To use Toggle in Unity3d

How To use Button Click in Unity3d

How To InputField text on Click in Unity3d

Learn Unity3d - How To Series

Recently I have launched short clip series where you can learn different things in unity3d. The journey has started with unity UI controls, Inn-Sha-Allah many more to come. Stay tuned to my blog!

Unity3d How To Series Video Tutorials:


  1. Unity UI - Button Click
  2. Unity UI - Get User input through UI InputFiled
  3. Unity UI - Get Selected option value in Unity UI dropdown
  4. Unity UI - Get Selected option Text in Unity UI dropdown
  5. Unity UI - Design Unity UI for multiple resolution
  6. Unity UI - Toggle Demo

Web Technology trends 2019


Thanks to "built with", we are sharing 2019 Web Technology trends.

Here is live website Count list:

Apache
65,506,144
 PHP
43,326,899
 ASP.NET
41,346,668
 Google Analytics
36,454,204
 WordPress
29,316,027
 Google Apps for Business
14,410,228
 Amazon
12,721,915
 Google Adsense
12,456,559
 J2EE
6,968,869
 Cart Functionality
5,800,597
 WooCommerce
4,146,137
 Wix
3,918,996
 New Relic
3,579,941
 Angular JS
2,482,906
 Joomla!
2,193,050
 MailChimp
2,083,402
 Drupal
1,631,782
 ASP.NET MVC
1,595,844
 Shopify
1,458,419
 Rackspace
1,352,858
 Ruby on Rails
1,178,845
 Omniture SiteCatalyst
898,414
 Taboola
816,713
 Zendesk
661,147
 Optimizely
645,237
 Stripe
620,002
 Hubspot
565,664
 Magento
555,796
 CodeIgniter
545,880
 Laravel
538,437
 OpenCart
483,098
 AdRoll
396,233
 PrestaShop
386,163
 Zen Cart
276,056
 Pardot
253,793
 Marketo
242,191
 Eloqua
240,697
 Adobe CQ
219,725
 ClickFunnels
185,092
 Adobe Experience Manager
173,566
 Magento 2
148,524
 Magento 1.9
137,587
 Salesforce
132,208
 Hybris
125,052
 Infusionsoft
121,384
 osCommerce
117,920
 Sitecore CMS
102,536
 BigCommerce
93,896
 Liferay
68,315
 nopCommerce
62,564
 RevContent
60,368
 Umbraco
56,250
 Kentico
46,639
 Magento Enterprise
43,212
 Demandware
34,127
 Shopify Plus
32,215
 Volusion
29,894
 Oracle Commerce
29,764
 IBM Websphere Commerce
21,257
 Magento 1.7
18,287